由於台 server 喺 load balancer 後面, 又唔想特登 set 多個 IP 用黎出 email, 再加上用 google 嚟出 email 唔駛驚俾人當 spam, 所以選擇用 google smtp。
用 Google smtp 有幾個問題, 首先佢地行 SSL 同埋核証用戶名稱同密碼, PHP 本身個 mail function 係唔 support, 我又唔想行 relay server, 所以就選擇經 msmtp。
首先要裝個 cygwin, 記得要選 msmtp。
然後就去修改 php.ini, 搵/加行 sendmail_path:
sendmail_path = “C:/cygwin/usr/sbin/msmtp -t -C C:/cygwin/etc/msmtp/msmtprc”
創建 C:/cygwin/etc/msmtp/msmtprc
account default
tls_starttls on
tls on
tls_certcheck off
host smtp.gmail.com
port 587
auth on
from 你個電郵地址
user 你個用戶名
password 你個密碼
logfile c:/log_files/msmtp.log
之後就大功告成
如果唔得
- check 下 php.ini 個 sendmail_path value 有冇 load 到
- 直接行 C:/cygwin/usr/sbin/msmtp -t -C C:/cygwin/etc/msmtp/msmtprc
- 行 C:/cygwin/usr/sbin/msmtp -d -t -C C:/cygwin/etc/msmtp/msmtprc, 用
To:test@youraccount.com [ENTER]
.[ENTER]
[ENTER]
黎 send email - PATH 一定要包括 C:\cygwin\bin, 如果唔係會 load 唔到某 d DLL





