首先你需要先到從http://glob.com.au/sendmail/下載sendmail.zip檔案,點此可以直接下載噢,然後把它解壓到如D:\php\sendmail\目錄下。
然後開啟php.ini檔案,找到下面這段代碼
複製代碼 代碼如下:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; sendmail_path = ""
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
預設情況下是以本機做為郵件伺服器,這裡我們需要借用sendmail來發送郵件,用sendmail來配置如用qq、163的郵箱來發送(一般都是以這種方式)所以我們需要把所有的選項都登出,即把SMTP = localhost和smtp_port = 25前面加上";"然後把sendmai_path=""前面的";"刪掉,改為sendmai_path="d:\php\sendmail\sendmail.exe -t",改完後的即是
複製代碼 代碼如下:
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "d:\php\sendmail\sendmail.exe -t"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
注意以上只需要開啟sendmail_path即可,然後儲存
接著修改sendmail目錄下的sendmail.ini檔案,主要填的內容有以下幾項
複製代碼 代碼如下:
smtp_server=smtp伺服器位址(如 smtp.ym.163.com)
auth_username=郵箱登入名稱(如 info@xxxx.com)
auth_password=郵箱密碼(如 xxxxxx)
force_sender=寄件者地址全寫(如 info@xxxx.com)
另外還有一項
複製代碼 代碼如下:
; auto = use SSL for port 465, otherwise try to use TLS
把前面的";"刪除,即開啟SSL安全登入選項即可
以上四項正確填寫修改完成後儲存,然後重啟IIS即可正常使用。
如果不能發送郵件,檢查下連接埠是不是被屏蔽了,mcafee是不是設定了禁止發送郵件等