13th Aug, 2008

Windows PHP 用msmtp經 Google 出 email

由於台 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

之後就大功告成
如果唔得

  1. check 下 php.ini 個 sendmail_path value 有冇 load 到
  2. 直接行 C:/cygwin/usr/sbin/msmtp -t -C C:/cygwin/etc/msmtp/msmtprc
  3. 行 C:/cygwin/usr/sbin/msmtp -d -t -C C:/cygwin/etc/msmtp/msmtprc, 用
    To:test@youraccount.com [ENTER]
    .[ENTER]
    [ENTER]
    黎 send email
  4. PATH 一定要包括 C:\cygwin\bin, 如果唔係會 load 唔到某 d DLL
分享這編文章:
  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • Yahoo! Buzz
  • StumbleUpon

相關文章

回應

我想問:

1) 你話 “首先要裝個 cygwin, 記得要選 msmtp”
意思係我選擇個版本時係要選擇 msmtp 的還是在安裝時選擇 msmtp 的?

2) 創建 C:/cygwin/etc/msmtp/msmtprc 的directory 後, 是開一個text file 將 account default 的資料打進去, 但我想問save 的file 名個檔案類型是有特定的嗎?

Dennis Cheng on 2008-11-18 10:04

你的回應






Your response: