PHP邮件被发送到垃圾邮件 [英] PHP Mail is Being Sent to Spam

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

问题描述

我知道这个网站上有很多类似的问题,但是没有一个对我有帮助.

I know that there are many similar questions on this site, but none of them helped me.

我有以下PHP代码:

<?php
$to = "mymail@inbox.com";
$from = "no-reply@heygee.com";
$subject = "Confirm your registration!";
$message = "Please follow this link to confirm your registration: www.bit.ly/32106";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: HeyGee! <no-reply@heygee.com>" . "\r\n" .
"Reply-To: mymail@inbox.com" . "\r\n" .
"X-Mailer: PHP/" . phpversion();

$ok = @mail($to, $subject, $message, $headers, "-f " . $from);   
?>

假设mymail@inbox.com是我的测试电子邮件.每当我将邮件发送到我的地址时,我始终会在垃圾邮件"文件夹中接收到该邮件.这是为什么?是否有任何更正或技巧可以阻止邮件到达垃圾邮件?

Let's say mymail@inbox.com is my test e-mail. Whenever I send the mail to my address, I always receive the mail in my Spam folder. Why is that? Are there any corrections or tricks to be made to prevent the mail from arriving in Spam?

谢谢.

推荐答案

将邮件发送到垃圾邮件"文件夹的原因是由于电子邮件的内容或接收方无法验证电子邮件是否实际上来自from地址中指定的域,即,发件人(您)是否有权代表heygee.com发送电子邮件.

The reason why your mail is being sent to Spam folder is either because of the content of your email or that the receiving side is not able to verify if the email actually came from the stated domain in the from address, i.e., if the sender (you) are authorized to send email on behalf of heygee.com.

内容部分易于纠正.您需要避免语法错误,链接含糊不清(例如,链接中标有google.com但指向example.com的链接)等.您的邮件应标明字词(排除垃圾邮件中经常出现的字词),最好包含以及(如果发送到邮件列表).

Content part is easy to correct. You need to avoid bad grammar, ambiguous links (e.g links which say google.com but point to example.com), etc. Your message should be well worded (exclude those words frequently found in spam mails), and preferably include an unsubscribe link as well (if sent to a mailing list).

现在是第二个困难的部分.您在from地址中写入的域应与您正在执行此邮件脚本的域相同,或者应由该域的TXT记录授权以代表其发送邮件.解决此问题的最简单方法是(前提是您拥有对发送域名的DNS访问权限)添加TXT SPF记录,以允许脚本所驻留的服务器的IP代表其发送邮件. 示例SPF记录:

Now comes the second and difficult part. The domain that you are writing in your from address should be the same domain from which you are executing this mail script or should be authorized by this domain's TXT records to send mail on its behalf. The simplest way to go about this would be (provided you have DNS access to the sending domain name) to add a TXT SPF record permitting the IP of the server your script resides on to send mail on its behalf. Example SPF record:

"v=spf1 ip6:1080::8:800:200C:417A/96 -all"

以上记录表示Allow any IPv6 address between 1080::8:800:0000:0000 and 1080::8:800:FFFF:FFFF.

结帐: SPF(Wikipedia)

此外,您可以在此处查看 http://www.openspf.org/

Also, you may have a look here http://www.openspf.org/

现在,如果您没有DNS访问权限,只需将from地址的域名更改为服务器的域名,它就可以对其进行修复.

Now if you don't have DNS access, then simply change the domain name of the from address to the domain name of the server and it should fix it.

希望有帮助.

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

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