php PHPMailer - 邮件直接发送到垃圾邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16717257/
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
PHPMailer - mails going straight to spam
提问by Chris
Whenever I send an automated e-mail using PHPMailer, it goes straight into the spam folder in Gmail. I have tried finding a solution to this myself but I don't know enough about e-mails and e-mail headers.
每当我使用 PHPMailer 发送自动电子邮件时,它都会直接进入 Gmail 中的垃圾邮件文件夹。我曾尝试自己找到解决方案,但我对电子邮件和电子邮件标题知之甚少。
Can anyone explain why this is happening?
谁能解释为什么会这样?
PHP Code is below, followed by the headers that show up from the receiver.
PHP 代码在下面,然后是从接收器显示的标题。
Thanks!
谢谢!
$mail = new PHPMailer;
$mail->From = "[email protected]";
$mail->FromName = 'Xenon Group Academy';
$mail->AddAddress($email);
$mail->Subject = "Your Xenon Group Academy login details";
$mail->IsHTML(true);
$mail->Body = "<html><body><h3>Welcome to the Xenon Group Academy</h3><p>The Academy is an online system that will allow you to access course materials, manage your assignments and network with other Xenon Group students.</p>
<p>To access your account, go to <a href='http://www.xenonacademy.org.uk'>www.xenonacademy.org.uk</a> and use the following details to login.</p><p><pre>E-mail: $email</pre></p><p><pre>Password: " . mysqli_real_escape_string($conn, $_POST['password']) . "</pre></p><br /><br /><p>Once you have logged in, we would recommend changing your password to something secure and easy to remember. You can also change your login e-mail address if you need to.</p><p>Welcome to the Academy, and good luck with your qualification!</p></body></html>";
$mail->Send();
Delivered-To: [email protected]
Received: by 10.49.109.71 with SMTP id hq7csp68808qeb;
Thu, 23 May 2013 07:27:28 -0700 (PDT)
X-Received: by 10.180.37.243 with SMTP id b19mr25275110wik.12.1369319247650;
Thu, 23 May 2013 07:27:27 -0700 (PDT)
Return-Path: <[email protected]>
Received: from server.xenonacademy.org.uk (vps69719724.123-vps.co.uk. [46.32.233.107])
by mx.google.com with ESMTPS id n5si14506537wic.103.2013.05.23.07.27.26
for <[email protected]>
(version=TLSv1 cipher=RC4-SHA bits=128/128);
Thu, 23 May 2013 07:27:27 -0700 (PDT)
Received-SPF: neutral (google.com: 46.32.233.107 is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=46.32.233.107;
Authentication-Results: mx.google.com;
spf=neutral (google.com: 46.32.233.107 is neither permitted nor denied by best guess record for domain of [email protected]) [email protected]
Received: by server.xenonacademy.org.uk (Postfix, from userid 10000)
id DFBAAE0288; Thu, 23 May 2013 15:27:24 +0100 (BST)
To: [email protected]
Subject: Your Xenon Group Academy login details
X-PHP-Originating-Script: 10000:class.phpmailer.php
Date: Thu, 23 May 2013 15:27:24 +0100
From: Xenon Group Academy <[email protected]>
Message-ID: <[email protected]>
X-Priority: 3
X-Mailer: PHPMailer 5.2.6 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=iso-8859-1
<html><body><h3>Welcome to the Xenon Group Academy</h3><p>The Academy is an online system that will allow you to access course materials, manage your assignments and network with other Xenon Group students.</p>
<p>To access your account, go to <a href='http://www.xenonacademy.org.uk'>www.xenonacademy.org.uk</a> and use the following details to login.</p><p><pre>E-mail: [email protected]</pre></p><p><pre>Password: xxxxxxxx</pre></p><br /><br /><p>Once you have logged in, we would recommend changing your password to something secure and easy to remember. You can also change your login e-mail address if you need to.</p><p>Welcome to the Academy, and good luck with your qualification!</p></body></html>
Thanks!
谢谢!
回答by Filippos Karapetis
This does sound more like a configuration issue with your mail server and/or your DNS server. Your mail server does not appear to be "trusted" enough, so you don't get enough "positive" points from GMail (and mail clients). I notice that you're using postfix as your mailer... Have you configured it properly?
这听起来更像是您的邮件服务器和/或 DNS 服务器的配置问题。您的邮件服务器似乎不够“受信任”,因此您没有从 GMail(和邮件客户端)获得足够的“积极”分数。我注意到您正在使用 postfix 作为您的邮件程序...您是否正确配置了它?
I would suggest you configure postfix first. For example, here's a guide on how to do it in CentOS:
我建议你先配置postfix。例如,以下是有关如何在 CentOS 中执行此操作的指南:
http://wiki.centos.org/HowTos/postfix
http://wiki.centos.org/HowTos/postfix
Second, you should add an SPF record to your DNS server:
其次,您应该向 DNS 服务器添加 SPF 记录:
http://en.wikipedia.org/wiki/Sender_Policy_Framework
http://en.wikipedia.org/wiki/Sender_Policy_Framework
Third, it would be good to have a reverse lookup entry for your server:
第三,最好为您的服务器设置一个反向查找条目:
http://en.wikipedia.org/wiki/Reverse_DNS_lookup
http://en.wikipedia.org/wiki/Reverse_DNS_lookup
You will need to do the above and some more to make sure that clients don't flag your mail as spam, and you don't get blacklisted
您将需要执行以上操作和其他操作,以确保客户不会将您的邮件标记为垃圾邮件,并且您不会被列入黑名单
Here's a good list of things to do to avoid getting blacklisted:
这里有一个很好的清单,可以做一些事情来避免被列入黑名单:
https://www.supportsages.com/prevent-your-mailip-from-getting-marked-as-spamblacklisted-a-few-tips/
https://www.supportsages.com/prevent-your-mailip-from-getting-marked-as-spamblacklisted-a-few-tips/
回答by Friendly Code
I use PHP Mailer a lot and haven't had any trouble with emails being sent to spam (yet!). I wonder if it might be anything to do with your 'from' email address as it's not the traditional [email protected]
我经常使用 PHP Mailer,并且在将电子邮件发送到垃圾邮件方面没有遇到任何问题(还没有!)。我想知道这是否与您的“发件人”电子邮件地址有关,因为它不是传统的 [email protected]
回答by Sagar Mathapati
It's because of the html body text headers. Put the simple text with some tags like strong underline etc and try.
这是因为 html 正文文本标题。将简单的文本与一些标签(如强下划线等)放在一起并尝试。