2011-11-21 185 views
1

這是我的代碼:PHP的郵件不能正常工作

if (mail('[email protected]','New booking', $_REQUEST['message'])) { 
echo"<p>Thanks for your booking!</p>"; 
} else { 
echo"<p>Booking failed, please call us to book...</p>"; 
} 

但不斷出現預訂失敗。我的服務器是centos vps。

/usr/local/lib/php.ini是這樣的:

[mail function] 
; For Win32 only. 
SMTP = localhost 
smtp_port = 25 

; For Win32 only. 
;sendmail_from = [email protected] 

; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
;sendmail_path = 

所以我改成了這樣:

[mail function] 
; For Win32 only. 
;SMTP = localhost 
;smtp_port = 25 

; For Win32 only. 
;sendmail_from = [email protected] 

; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
sendmail_path = "/usr/sbin/sendmail -t -i" 

這仍然無法正常工作,現在我出來的想法。每次編輯完php.ini後,我重新啓動服務器

+0

sendmail在'/ var/log/messages'中發現錯誤你有沒有什麼用處? – Kleist

+0

消息中沒有內容:/ – user964778

回答

0

不知道爲什麼,但是directadmin更改了導致它失敗的exim文件夾的權限。

0

您需要在mail()的電話中提供From:地址。這是大多數SMTP服務器和sendmail所必需的。

+0

將其更改爲if(mail('[email protected]','New booking',$ _REQUEST ['message'],'From:[email protected]')){但仍然沒有 – user964778