2011-11-21 183 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