PHPMailer 电子邮件发送成功但未收到 (EC2)
Posted
技术标签:
【中文标题】PHPMailer 电子邮件发送成功但未收到 (EC2)【英文标题】:PHPMailer email sent successfully but not received (EC2) 【发布时间】:2017-08-25 07:50:10 【问题描述】:我在 EC2 上使用 phpMailer。我的帐户不在沙盒中,我从经过验证的电子邮件发送。我没有从 PHPMailer 收到任何错误,这就是我的日志
2017-03-31 06:24:52 Connection: opening to email-smtp.us-west-2.amazonaws.com:587, timeout=300, options=array ( )
2017-03-31 06:24:52 Connection: opened
2017-03-31 06:24:53 SERVER -> CLIENT: 220 email-smtp.amazonaws.com ESMTP SimpleEmailService-2007935443 svKFRJ5M6s1rqbMTRdZu
2017-03-31 06:24:53 CLIENT -> SERVER: EHLO ***.domain
2017-03-31 06:24:53 SERVER -> CLIENT: 250-email-smtp.amazonaws.com 250-8BITMIME 250-SIZE 10485760 250-STARTTLS 250-AUTH PLAIN LOGIN 250 Ok
2017-03-31 06:24:53 CLIENT -> SERVER: STARTTLS
2017-03-31 06:24:53 SERVER -> CLIENT: 220 Ready to start TLS
2017-03-31 06:24:53 CLIENT -> SERVER: EHLO ***.domain
2017-03-31 06:24:53 SERVER -> CLIENT: 250-email-smtp.amazonaws.com 250-8BITMIME 250-SIZE 10485760 250-STARTTLS 250-AUTH PLAIN LOGIN 250 Ok
2017-03-31 06:24:53 CLIENT -> SERVER: AUTH LOGIN
2017-03-31 06:24:53 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2017-03-31 06:24:53 CLIENT -> SERVER: xxx=
2017-03-31 06:24:53 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2017-03-31 06:24:53 CLIENT -> SERVER: xxx=
2017-03-31 06:24:53 SERVER -> CLIENT: 235 Authentication successful.
2017-03-31 06:24:53 CLIENT -> SERVER: MAIL FROM:
2017-03-31 06:24:53 SERVER -> CLIENT: 250 Ok
2017-03-31 06:24:53 CLIENT -> SERVER: RCPT TO:
2017-03-31 06:24:53 SERVER -> CLIENT: 250 Ok
2017-03-31 06:24:53 CLIENT -> SERVER: DATA
2017-03-31 06:24:53 SERVER -> CLIENT: 354 End data with .
2017-03-31 06:24:53 CLIENT -> SERVER: Date: Fri, 31 Mar 2017 06:24:52 +0000
2017-03-31 06:24:53 CLIENT -> SERVER: To: NG
2017-03-31 06:24:53 CLIENT -> SERVER: From: Me
2017-03-31 06:24:53 CLIENT -> SERVER: Subject: New User Added
2017-03-31 06:24:53 CLIENT -> SERVER: Message-ID: <8ada86808c4dc38c21d7ff5d64051951@***.domain>
2017-03-31 06:24:53 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.21 (https://github.com/PHPMailer/PHPMailer)
2017-03-31 06:24:53 CLIENT -> SERVER: MIME-Version: 1.0
2017-03-31 06:24:53 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1
2017-03-31 06:24:53 CLIENT -> SERVER:
2017-03-31 06:24:53 CLIENT -> SERVER: 123
2017-03-31 06:24:53 CLIENT -> SERVER:
2017-03-31 06:24:53 CLIENT -> SERVER: .
2017-03-31 06:24:53 SERVER -> CLIENT: 250 Ok 0101015b2309bfbe-39a8cf31-ad57-4998-832d-94312b7ddfad-000000
2017-03-31 06:24:53 CLIENT -> SERVER: QUIT
2017-03-31 06:24:53 SERVER -> CLIENT: 221 Bye
2017-03-31 06:24:53 Connection: closed
这是我的 PHPMailer 设置
$this->SMTPDebug = 3;
$this->Host = 'email-smtp.us-west-2.amazonaws.com';
$this->Username = '***';
$this->Password = '***';
$this->SMTPAuth = true;
$this->SMTPSecure = 'tls';
$this->Port = 587;
$this->isHTML(true);
$this->isSMTP();
$this->From = '***';
$this->FromName = '***';
$this->ReturnPath = '***';
我尝试将其发送到不同的电子邮件,但仍然无法正常工作。这是发送的实际代码
$mailer = new Mailer($API);
$mailer->Subject = 'New User Added';
$mailer->Body = '123';
$mailer->addAddress('***', '***');
if (!$mailer->send())
throw new Exception($mailer->ErrorInfo);
else
print_r('Sent');
【问题讨论】:
您收到了哪种类型的delivery notification 消息,它说了什么? AWS EC2 email sending limit when using third party smtp server的可能重复 @sqlbot 我只从 PHP 得到这个日志。没有收到任何其他通知。 @Putnik “如果您没有连接到端口 25 上的第 3 方服务器,那么绝对没有限制。”我只连接 587 PHPMailer的参与在提交成功后结束。您遇到的任何其他问题与您的代码无关。我从您的问题中删除了您的密码 - 您可能想要更改它。 【参考方案1】:我遇到了同样的问题,当我设置 $mail->Username = 'xx@xx.xx'; 时它消失了到与 $mail->setFrom('xx@xx.xx') 中相同的地址
【讨论】:
【参考方案2】:对我来说,问题是因为我还没有收到来自这个地址的邮件,所以所有邮件都在垃圾邮件文件夹中
【讨论】:
【参考方案3】:我建议您转到https://www.mail-tester.com/,然后复制您看到的电子邮件地址。更新您的代码,然后使用 PHPMailer 向您复制的地址发送电子邮件。假设您的代码确实发送了电子邮件,并且看起来您的代码是正确的,那么 Mail Tester 将向您显示您的电子邮件存在哪些问题。
【讨论】:
非常感谢 - 这个网站帮助我发现了 SPF 记录问题。 这真的很有帮助,因为它都属于垃圾邮件文件夹以上是关于PHPMailer 电子邮件发送成功但未收到 (EC2)的主要内容,如果未能解决你的问题,请参考以下文章