讓 Piwigo 使用 Gmail 寄送郵件

伺服器設定、架站預 CMS 相關的主題。
回覆文章
頭像
sunsir.code
文章: 4
註冊時間: 2016-02-04, 02:49
Gender:

讓 Piwigo 使用 Gmail 寄送郵件

文章 sunsir.code »

免責聲明
本文僅供參考,不負任何損害賠償之責任,請閱讀者自行斟酌,並後果自負。

Piwigo 是很容易使用的相冊 CMS,但它的郵件寄送系統通常必須手動設定一下才能正常使用 Gmail。本文分享如何設定。

測試環境
  • apache 2.4.XX
  • PHP 7.4
  • 作業系統 almalinux9.0/8.6 rockylinux9.0/8.6
  • Piwigo 12.3.0

步驟一:
下載新版的 PHPMailer
https://github.com/PHPMailer/PHPMailer/ ... master.zip
然後解壓縮該檔案,並將其 src 檔案夾中的檔案拷貝覆蓋到 /where_is_piwigo_root_directory/include/phpmailer/


步驟二:
修改 /where_is_piwigo_root_directory/include/functions_mail.inc.php

將:

代碼: 選擇全部

  include_once(PHPWG_ROOT_PATH.'include/phpmailer/class.smtp.php');
  include_once(PHPWG_ROOT_PATH.'include/phpmailer/class.phpmailer.php');

  $mail = new PHPMailer;
改成:

代碼: 選擇全部

  include_once(PHPWG_ROOT_PATH. 'include/phpmailer/PHPMailer.php');
  include_once(PHPWG_ROOT_PATH. 'include/phpmailer/SMTP.php');
  include_once(PHPWG_ROOT_PATH. 'include/phpmailer/Exception.php');

 $mail = new PHPMailer;
步驟三:
啓用 Gmail 兩步認證與 App Password 。如果不知道怎麼做可以參考這篇文章:
https://medium.com/@kumardeepak.xyz/how ... c66332a017


步驟四:
然後 /where_is_piwigo_root_directory/local/config/config.inc.php
內容如下:

代碼: 選擇全部

<?php

$conf['smtp_host'] = 'smtp.gmail.com:587';
$conf['smtp_user'] = 'ENTER YOUR GOOGLE ACCOUNT EMAIL';
$conf['smtp_password'] = 'ENTER YOUR APP PASSWORD HERE';
$conf['mail_allow_html'] = true;
$conf['smtp_secure'] = tls;

?>
這樣就完成了,測試一下可以正常發送郵件了。😊
免責聲明
本文僅供參考,不負任何損害賠償之責任,請閱讀者自行斟酌,並後果自負。
回覆文章