【问题标题】:php mail not workingphp邮件不工作
【发布时间】:2012-01-03 06:15:02
【问题描述】:

这是我的代码:

if (mail('email@mail.com','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 = me@example.com

; 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 = me@example.com

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

这仍然不起作用,现在我没有想法了。每次编辑 php.ini 后我都重新启动了我的服务器

【问题讨论】:

  • sendmail 把它的错误放在/var/log/messages 那里你觉得有什么有用的吗?

标签: php email centos sendmail


【解决方案1】:

您需要在致电mail() 时提供From: 地址。这是大多数 SMTP 服务器和sendmail 所要求的。

【讨论】:

  • 将其更改为 if (mail('my@email.com','New booking', $_REQUEST['message'], 'From: other@email.com')) { 但仍然什么都没有
【解决方案2】:

不知道为什么,但是 directadmin 更改了 exim 文件夹的权限导致它失败。

【讨论】:

    猜你喜欢
    • 2013-06-03
    • 2017-10-27
    • 2013-10-05
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 2016-03-04
    • 2015-08-14
    • 1970-01-01
    相关资源
    最近更新 更多