简体   繁体   English

PHP mail()-未收到电子邮件

[英]PHP mail() - Email not received

I have set up an AJAX contact form on a client's website. 我已经在客户的网站上建立了AJAX联系表格。

The problem is that the email is not getting through to the client's inbox. 问题在于电子邮件无法到达客户的收件箱。

I set up the client with Google Apps (in the same way I did for myself). 我使用Google Apps设置了客户端(使用与自己相同的方式)。

I used the same contact form with my email address and it works. 我使用了与我的电子邮件地址相同的联系方式,并且有效。 But with any email addresses on their domain it doesn't! 但是,在其域中的任何电子邮件地址中都不会!

All members of the domain are receiving 'ordinary' emails. 该域的所有成员都将收到“普通”电子邮件。

What could be the difference that's stopping mail() emails getting through? 阻止mail()电子邮件通过有什么区别?


UPDATE 更新

Ok so I managed to solve it. 好的,所以我设法解决了。 Turns out that using a CNAME to point the domain to the correct server wasn't enough for sendmail so I had to change it to an A record pointing directly to the server. 事实证明,使用CNAME将域指向正确的服务器还不足以发送sendmail,因此我不得不将其更改为直接指向服务器的A记录。 Strange but true. 奇怪但真实。 Thanks for the help folks, you pointed me in the right direction :) 感谢您的帮助,您指出了我正确的方向:)

It depends on the both settings on your server and the server on the receiving end. 它取决于服务器和接收端服务器上的两个设置。

hotmail for example requires the use of correctly configured SPF records . 例如,hotmail要求使用正确配置的SPF记录

many mail-receiving servers (including hotmail) require the email to originate from a Fully Qualified Domain Name . 许多邮件接收服务器(包括hotmail)都要求电子邮件源于“ 完全合格的域名” It is very possible that your e-mails send from PHP do not comply with this rule. 您从PHP发送的电子邮件很可能不符合此规则。 (there is a good chance they originate from 'apache') (它们很有可能来自“ apache”)
see hotmail self help and hotmail postmaster info 查看hotmail自助hotmail邮件管理员信息

PHP's mail() function does not include a lot of headers with your mail, so you will need to supply them yourself. PHP的mail()函数的邮件中没有包含很多标头,因此您需要自己提供它们。

The more hops your mail makes on it's way to it destination, the more likely it is to be tagged as spam. 您的邮件在发送到目的地的途中跳越多,则更有可能被标记为垃圾邮件。 So it might be a better option not to use PHP's mail function and instead use a mail library that connects to an SMTP server just like your desktop mail application does. 因此,最好不要使用PHP的邮件功能,而要像桌面邮件应用程序一样使用连接到SMTP服务器的邮件库 ,这是一个更好的选择。

All in all, I would place my bets on an external library: Pear::Mail ( documentation ) 总而言之,我将赌注放在一个外部库上: Pear :: Mail文档

You could also read: how do you make sure email you send programmatically is not automatically marked as spam 您还可以阅读以下内容: 如何确保以编程方式发送的电子邮件不会自动标记为垃圾邮件

UPDATE 更新
Failing the SenderId or SPF check can get your message dropped before it even hits the users inbox. 如果未通过SenderId或SPF检查,则您的消息会在到达用户收件箱之前就被丢弃。 The message will not end up in the users junk folder, it will go directly to /dev/null. 该消息不会最终出现在用户的垃圾文件夹中,而是直接转到/ dev / null。 I know this is at least true for hotmail and live mail. 我知道这至少对于Hotmail和实时邮件是正确的。 I see no reason for other hosts not to have implemented the same policy. 我看不出其他主机没有实施相同策略的原因。

I recommend using PHPMailer (including their SMTP) library instead. 我建议改为使用PHPMailer(包括其SMTP)库。 It is reliable compared to mail and allows you to create fully customized emails. 与邮件相比,它是可靠的,并允许您创建完全自定义的电子邮件。

http://phpmailer.worxware.com/ http://phpmailer.worxware.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM