PHP邮件停止工作 [英] PHP mail stopped working

查看:91
本文介绍了PHP邮件停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,当使用 mail()时,我已经正常工作。



但现在不工作。我不知道问题是什么。

  $ to ='testmail@gmail.com'; 
$ subject ='主题';
$ message ='hello';
$ headers ='From:sender@gmail.com'。 \\\\。
'Reply-To:sender@gmail.com'。 \\\\。
'X-Mailer:PHP /'。 phpversion();

mail($ to,$ subject,$ message,$ headers);

$ mail_sent = @mail($ to,$ subject,$ message,$ headers);
echo $ mail_sent? 邮件发送:邮件失败;

它显示发送邮件。



我没有在Apache或这段代码中触及任何东西。我已经在一个空的PHP文件中测试了相同的结果代码。如何调试这个问题?

解决方案

可能是电子邮件发送正常,但被垃圾邮件过滤?
如果可能,请允许我交叉发布自己






几个项目符号(假设mail()返回true,错误日志中没有错误) p>


  • 发件人地址(From)是否属于您的服务器上的域?如果没有,就这样做。

  • 您的服务器是否在黑名单上(例如,检查spamhaus.org上的IP)?这是共享托管的一个遥远的可能性。

  • 是否通过垃圾邮件过滤器过滤邮件?打开一个带有垃圾邮件文件夹的freemailer帐户,并找出。另外,尝试发送邮件到没有垃圾邮件过滤器的地址。

  • 您可能需要mail()的第五个参数-f来添加发件人地址吗? (请参阅PHP手册中的mail()命令)

  • 如果您可以访问日志文件,请查看这些,当然,如上所述。

  • 您是否检查from:地址以获取可能的反弹邮件(返回发件人)?你也可以设置一个单独的错误到地址。



对于德国的演讲者,我写了一个相当详尽的在这个问题前一段时间。请参阅 here


Some days ago when using mail() I had it working.

But now it doesn't work. And I don't know what the problem is.

$to      = 'testmail@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: sender@gmail.com' . "\r\n" .
    'Reply-To: sender@gmail.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

$mail_sent = @mail( $to, $subject, $message, $headers ); 
echo $mail_sent ? "Mail sent" : "Mail failed";

It displays "Mail sent".

I haven't touched anything in Apache or this code. I have tested the code in an empty PHP file with the same result. How can I debug this problem?

解决方案

Could it be that E-Mails are being sent fine, but are caught by a spam filter? If this could be, allow me to cross-post myself:


A few bullet points (Assuming that mail() returns true and there are no errors in the error log) :

  • Does the sender address ("From") belong to a domain on your server? If not, make it so.
  • Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a remote possibility with shared hosting.
  • Are mails filtered by a spam filter? Open an account with a freemailer that has a spam folder and find out. Also, try sending mail to an address without a spam filter.
  • Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)
  • If you have access to log files, check those, of course, as suggested above.
  • Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.

For german speakers, I have written a quite exhaustive "what to do" on this issue some time ago. See here.

这篇关于PHP邮件停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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