sendmail工作但PHP mail()失败 [英] sendmail working but PHP mail() is failing

查看:144
本文介绍了sendmail工作但PHP mail()失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法使用PHP的邮件()发送电子邮件。我也试过PHPMailer和Swiftmail没有成功。但是,服务器上的以下命令会成功发送邮件。

I cant seem to send an email using PHP's mail(). I have also tried PHPMailer and Swiftmail with no success. However, the following command on the server delivers mail successfully.

cat test.txt | mail -s "test mail" my@email.com 

有没有办法跟踪哪里的问题来自哪里? mail()只是似乎返回true或false。

Is there a way to trace where the problem is coming from? mail() just seems to return true or false.

推荐答案

在PHP> = 5.2,有 error_get_last() 来检索最后一个函数调用返回的错误。有关如何从链接页面上的旧版本PHP获取等价信息的详细信息。

On PHP >= 5.2, there's error_get_last() to retreive whatever error was returned by the last function call. There's details on how to get equivalent information from older versions of PHP on the linked page.

对于PHPMailer,有$ code> $ mailer->包含最后一个错误的ErrorInfo 属性。 SwiftMailer必须有类似的东西。最有可能的是,如果邮件从命令行工作,但不是从PHP或邮件库中运行,则配置错误。我猜你的主机没有配置PHP sendmail_path ini参数。

As for PHPMailer, there's the $mailer->ErrorInfo property which contains the last error occured. SwiftMailer must have something similar. Most likely if mail's working from the command line but not from within PHP or the mailing libraries, there's a misconfiguration at play. I'm guessing your host doesn't have the PHP sendmail_path ini parameter configured.

这篇关于sendmail工作但PHP mail()失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆