首先你需要先到從下載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 =
默認(rèn)情況下是以本機(jī)做為郵件服務(wù)器,這里我們需要借用sendmail來發(fā)送郵件,用sendmail來配置如用qq、163的郵箱來發(fā)送(一般都是以這種方式)所以我們需要把所有的選項都注銷,即把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文件,主要填的內(nèi)容有以下幾項
代碼如下
smtp_server=smtp服務(wù)器地址(如 smtp.ym.163.com)
auth_username=郵箱登錄名(如 info@xxxx.com)
auth_password=郵箱密碼(如 xxxxxx)
force_sender=發(fā)件人地址全寫(如 info@xxxx.com)
另外還有一項
代碼如下
; auto = use SSL for port 465, otherwise try to use TLS
把前面的";"刪除,即開啟SSL安全登錄選項即可
以上四項正確填寫修改完成后保存,然后重啟IIS即可正常使用,現(xiàn)在很高興地測試我的wordpress博客了
現(xiàn)在開始調(diào)試wordpress博客,但發(fā)現(xiàn)服務(wù)器無法發(fā)送郵件,sendmail已經(jīng)安裝,但是繼續(xù)提示郵件發(fā)送不成功。分析了很久,總算找到了原因
第一步:安裝sendmail服務(wù)
下載sendmail.RAR存放至php目錄下的sendmail目錄
第二步、配置php.ini文件
代碼如下
sendmail_path =”D:/php/sendmail/sendmail.exe -t”
盤符和位置根據(jù)sendmail.exe文件位置確定
第三步、配置sendemail.ini
代碼如下
smtp_server=smtp.sina.com.cn
smtp_port=25
這倆個是要求驗證的時候的賬號,密碼
auth_username=ifbs
auth_password=XXXX
第四步、給予cmd.exe權(quán)限
C:/WINDOWS/system32/cmd.exe 文件以 users的讀權(quán)限。不給予權(quán)限會出現(xiàn)以下錯誤。
Warning: mail() [function.mail]: Could not execute mail delivery program
第五步、建立mail.php文件測試結(jié)果
代碼如下
<?php
$mail = “xxxx@sina.com.cn”;
$subject = “Mail Test”;
$text = “This is a test mail for function mail()”;
if(mail($mail,$subject,$text)){
echo “email send success!”;
}else{
echo “email send fail!”;
}
?>
訪問mail.php即可測試結(jié)果