我正在尝试使用 php 的 mail() 函数,但一直出现错误。我已经通过 sudo apt-get install sendmail
安装了 sendmail,编辑了我的 /etc/php5/cli/php.ini
文件,在这些行中添加了以下文本:
sendmail_path = /usr/sbin/sendmail -t
sendmail_from = uslonsweb003.ALU@no-reply.com
然后我重新启动了我的网络服务器并使用这个命令进行测试:
:~$ php -r "mail('sadmicrowave@gmail.com', 'test subject', 'test body message');"
但我每次都会收到以下错误!!!:
sh: -t: not found
这很奇怪,因为我已经尝试过使用 -t 和不使用 -t 的 sendmail_path,但我总是遇到同样的错误。我做错了什么?
更新!这是我的 phpinfo() 显示的内容:(我添加了 -t 但无论有没有它命令都不起作用)。
另一个更新 -
我注释掉了 sendmail_path 和 sendmail_from 行以从头开始期望 mail() 函数提示 php 不知道它是什么但是我得到了与以前完全相同的错误(即使完全没有这两行! !)。这让我相信它与 sendmail 程序或 mail() 函数根本无关......
最佳答案
我不知道,但您可以尝试 sendmail_path =/usr/sbin/sendmail -t -i
。它是在我使用的虚拟主机上设置的。否则,您可能需要检查 phpinfo()
是否包含正确的 sendmail
设置。
关于php5 mail() 函数发送邮件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5869705/