php PHPmailer 发送到垃圾邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6567213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:44:35  来源:igfitidea点击:

PHPmailer sends to junk email

phpphpmailer

提问by hooligan

I've just updated a contact form to use PHPMailer to stop emails being marked as junk, with no luck.

我刚刚更新了一个联系表格,以使用 PHPMailer 来阻止电子邮件被标记为垃圾邮件,但不幸的是。

It's a fairly straight forward setup I'm using but its still going into peoples junk mail.

这是我正在使用的一个相当直接的设置,但它仍然会进入人们的垃圾邮件。

Here is my script, I was wondering if anyone could tell what was wrong?

这是我的脚本,我想知道是否有人能告诉我出了什么问题?

include_once('../inc/phpmailer/class.phpmailer.php');

$mail = new PHPMailer();

$name = $_POST['name'];
$email = $_POST['email'];
$body = "Name: ".$name."\r\n";
$body .= "Email: ".$email."\r\n";
$body .= "Message: ".$_POST['message'];

$mail->From       = "[email protected]";
$mail->FromName   = "Contact BLah";

$mail->Subject    = "Contact From: Blah";

$mail->Body = $body;

$mail->AddAddress("[email protected]", "john");
$mail->AddAddress("[email protected]", "david");

if(!$mail->Send()) {
  $errorMsg .= "Error sending message, please try again later.";
} else {
  $errorMsg .= "Message Sent successfully.";
}

I thought that PHPmailer normally takes care of inserting proper headers?

我认为 PHPmailer 通常负责插入正确的标题?

Any thoughts?

有什么想法吗?

EDIT: Added spam score

编辑:添加垃圾邮件分数

-Spam-Status: "score=0.0 tests=none version=3.1.7 cmae=v=1.0 c=1 a=8nJEP1OIZ-IA:10 a=soyWjZv28gkhNSke5wm04A==:17 a=fqdOs_Nl9wd82e3SDigA:9 a=l-lynuxnH-gfU2bevBoA:7 a=wPNLvfGTeEIA:10 a=nymK5Bb5l1cA:10 a=_6wjLm_vFSYA:10 xcat=Undefined/Undefined" X-Spam-Level: *

-垃圾邮件状态:“分数=0.0 测试=无版本=3.1.7 cmae=v=1.0 c=1 a=8nJEP1OIZ-IA:10 a=soyWjZv28gkhNSke5wm04A==:17 a=fqdOs_Nl9wd82e3SDigly-nuxn=9 a gfU2bevBoA:7 a=wPNLvfGTeEIA:10 a=nymK5Bb5l1cA:10 a=_6wjLm_vFSYA:10 xcat=Undefined/Undefined" X-垃圾邮件级别:*

EDIT 2: I just tried the script on a different server from the clients and it has the same result. Do I have to send through the SMTP setup for it not to be classed as spam?

编辑 2:我只是在与客户端不同的服务器上尝试了该脚本,结果相同。我是否必须通过 SMTP 设置发送才能不被归类为垃圾邮件?

回答by Marc B

Some reasons your mail can get marked spam:

您的邮件可能被标记为垃圾邮件的一些原因:

  1. You're sending spam
  2. Your IP, or a block of IPs surrounding your IP has been marked as a spam source on one or more blackhole lists
  3. The content of the email is triggering spam filters.
  4. The recipient has added you to their blacklist
  5. The recipient didn't add you to their whitelist
  6. You're sending a mixed source mail ("From: [email protected]", but sending it from "someotherdomain.net")
  7. SPF records for your server are misconfigured/not configured at all
  8. Domain keys are misconfigured/not configured at all
  1. 您正在发送垃圾邮件
  2. 您的 IP 或围绕您 IP 的一组 IP 已在一个或多个黑洞列表中标记为垃圾邮件源
  3. 电子邮件的内容正在触发垃圾邮件过滤器。
  4. 收件人已将您添加到他们的黑名单
  5. 收件人没有将您添加到他们的白名单
  6. 您正在发送混合源邮件(“来自:[email protected]”,但从“someotherdomain.net”发送)
  7. 您服务器的 SPF 记录配置错误/根本未配置
  8. 域密钥配置错误/根本没有配置

etc...

等等...

PHPMailer is a tool. Consider it a hammer. The hammer may have bent the nail, but only because the wielder didn't aim right.

PHPMailer 是一个工具。把它当作锤子。锤子可能弄弯了钉子,但这只是因为持用者没有正确瞄准。

The only way you'll solve this problem is by examining the bounce messages (if any), and whatever showed up in the recipient's mailbox. If they receive the mail, but it goes into a spam folder, then get a copy of the mail and examine its headers. Most spam filters will put their spam score/reasoning in there.

解决此问题的唯一方法是检查退回邮件(如果有)以及收件人邮箱中显示的任何内容。如果他们收到邮件,但它进入了垃圾邮件文件夹,则获取邮件副本并检查其标题。大多数垃圾邮件过滤器会将他们的垃圾邮件分数/推理放在那里。

回答by marklark

Small hint:

小提示:

add in a line like so

像这样添加一行

 $mail->AddReplyTo( '[email protected]', 'Contact BLah' );

It should decrease your SPAM rating significantly.

它应该会显着降低您的垃圾邮件评级。

回答by skuipho

I was having the same problem using PHPMailer, and here's what fixed the problem for me: set the Sender (this is different and distinct from the "From") to a valid email account for the domain you are sending the email from. This causes PHPMailer to properly set the "envelope-from" information so that the email passes SPF and Sender-ID validation. Without doing this, the "envelope-from" is a OS user id and server combination which will not be verifiable.

我在使用 PHPMailer 时遇到了同样的问题,这是为我解决问题的方法:将发件人(这与“发件人”不同且不同)设置为您发送电子邮件的域的有效电子邮件帐户。这会导致 PHPMailer 正确设置“信封发件人”信息,以便电子邮件通过 SPF 和发件人 ID 验证。如果不这样做,“信封来自”是无法验证的操作系统用户 ID 和服务器组合。

Example Code:

示例代码:

$mail = new PHPMailer;

$mail->From = '[email protected]';
$mail->Sender = '[email protected]';
...

回答by Tudor Constantin

It is not necessarily PHPMailer's fault, there are several possible reasons for your server to be blacklisted. You can check hereto see if this happened

这不一定是 PHPMailer 的错,您的服务器被列入黑名单有多种可能的原因。你可以在这里查看是否发生了这种情况