php5 mail()函数sendmail错误

2023-12-15

我正在尝试使用 php 的 mail() 函数,但不断收到错误。我已经通过安装了sendmailsudo apt-get install sendmail,编辑了我的/etc/php5/cli/php.ini文件将以下文本添加到这些行:

 sendmail_path = /usr/sbin/sendmail -t
 sendmail_from = [email protected]

然后我重新启动了我的网络服务器并使用此命令进行测试:

 :~$ php -r "mail('[email protected]', 'test subject', 'test body message');"

但我每次都会收到以下错误!!!:

 sh: -t: not found

这很奇怪,因为我尝试了带 -t 和不带 -t 的 sendmail_path 但我不断收到相同的错误。我究竟做错了什么?

更新!这就是我的 phpinfo() 显示的内容:(我添加了 -t 回来,但无论有没有它,该命令都无法工作)。

enter image description here

另一个更新 -

我注释掉了 sendmail_path 和 sendmail_from 行,从头开始期望 mail() 函数抱怨 php 不知道它是什么,但我得到了与以前完全相同的错误(即使完全没有这两行!!)。这让我相信它根本与 sendmail 程序或 ma​​il() 函数无关......


我不知道,但你可以尝试一下sendmail_path = /usr/sbin/sendmail -t -i。我使用的虚拟主机上是这样设置的。否则,您可能想检查是否phpinfo()包含正确的设置sendmail.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

php5 mail()函数sendmail错误 的相关文章