【问题标题】:AOL mail rejected using smtplib使用 smtplib 拒绝 AOL 邮件
【发布时间】:2015-12-28 07:12:36
【问题描述】:

我正在使用smtplib 通过 AOL 帐户发送电子邮件,但在成功验证后它被拒绝并出现以下错误。

reply: '521 5.2.1 :  AOL will not accept delivery of this message.\r\n'
reply: retcode (521); Msg: 5.2.1 :  AOL will not accept delivery of this message.
data: (521, '5.2.1 :  AOL will not accept delivery of this message.')

这里是这个错误的解释。

The SMTP reply code 521 indicates an Internet mail host DOES NOT ACCEPT
incoming mail. If you are receiving this error it indicates a configuration
error on the part of the recipient organisation, i.e. inbound e-mail traffic
is being routed through a mail server which has been explicitly configured
(intentionally or not) to NOT ACCEPT incoming e-mail.

收件人邮件(在我的脚本中)是有效的 (gmail) 地址,并且在此调试消息后邮件被拒绝。

send: 'Content-Type: text/plain; charset="us-ascii"\r\nMIME-Version:    1.0\r\nContent-Transfer-Encoding: 7bit\r\nSubject: My reports\r\nFrom: myAOLmail@aol.com\r\nTo: reportmail@gmail.com\r\n\r\nDo you have my reports?\r\n.\r\n'

这是代码的简短版本:

r_mail = MIMEText('Do you have my reports?')
r_mail['Subject'] = 'My reports'
r_mail['From'] = e_mail
r_mail['To'] = 'reportmail@gmail.com'

mail = smtplib.SMTP("smtp.aol.com", 587)
mail.set_debuglevel(True)
mail.ehlo()
mail.starttls()
mail.login(e_mail, password)
mail.sendmail(e_mail, ['reportmail@gmail.com'] , r_mail.as_string())

这是某种权限问题,因为我使用 Yahoo 帐户成功发送了相同的电子邮件,没有任何问题吗?

【问题讨论】:

  • 您可以从同一个 AOL 帐户发送电子邮件吗?我的意思是使用网络浏览器。这个问题是 AOL 方面的问题。
  • @ρss 谢谢!我得检查一下这个帐户有什么问题。我刚刚尝试了另一个帐户,它成功了。
  • 是的,正如我所提到的,该特定帐户或 AOL 存在问题。 python脚本没有问题!也许您违反了 AOL 电子邮件服务的条款和条件,或者此 AOL 帐户正在发送垃圾邮件。

标签: python mail-server smtplib aol


【解决方案1】:

我猜 AOL 默认不允许中继访问,或者您没有手动配置它。您收到的错误表明 aol 没有您要发送消息的收件人。在这种情况下,如果您想向 gmail 帐户发送电子邮件,请尝试连接到 gmail SMPT 服务器而不是 AOL。

例如将 smpt 服务器更改为 gmail-smtp-in.l.google.com 并关闭身份验证。

【讨论】:

  • 我认为 OP 希望使用 AOL 服务器从 AOL 帐户向 Gmail 帐户发送一封电子邮件。我认为 OP 面临的问题与 AOL 服务器或电子邮件服务有关,而不是 Gmail。
  • 是的,但是 OP 可以简单地将 From 标头设置到他的 AOL 帐户,这种方法的唯一问题是主要的 ESP 在您的消息中需要 DKIM 和 SPF 标头,如果没有它,消息可能会命中垃圾邮件文件夹。如果这无关紧要,OP 可以尝试我描述的解决方案。
【解决方案2】:

我自己从 AOL SMTP 中继遇到5.2.1 : AOL will not accept delivery of this message.。我最终需要的是 MIME 消息正文中的有效 From 和 To 标头,而不仅仅是 SMTP 连接。

在您的特定情况下,获得此 5.2.1 反弹的原因可能有很多。 postmaster.aol.com 站点有一些有用的诊断工具,以及一些关于这个特定错误消息的非常模糊的文档。就我而言,我最终嗅探了我的 Thunderbird 电子邮件客户端与 Python 脚本发送的 SMTP 消息的数据包,并最终发现了差异。

postmaster.aol.com 文档:

https://postmaster.aol.com/error-codes

AOL 不接受此邮件的传递
这是一个永久性的反弹,原因是:

  • RFC2822 From domain 与发送服务器的 rDNS 不匹配。
  • RFC 2822 FROM 地址没有 A 记录并且不是有效域。
  • IP 声誉不佳,邮件被发送给多个收件人。
  • 邮件标头中有多个发件人地址,IP信誉不佳。

我通过 smtp.aol.com 发送邮件的 Python 函数:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

def genEmail(user, passwd, to, subject, message):
    smtp=smtplib.SMTP_SSL('smtp.aol.com',465)
    smtp.login(user, passwd)

    msg = MIMEMultipart()
    msg['Subject'] = subject
    msg['From'] = user # This has to exist, and can't be forged
    msg['To'] = to
    msg.attach(MIMEText(message, 'plain'))

    smtp.sendmail(user, to, msg.as_string())
    smtp.quit()

【讨论】:

    猜你喜欢
    • 2016-05-19
    • 2014-09-14
    • 2014-09-02
    • 2017-07-01
    • 2015-02-03
    • 1970-01-01
    • 2018-08-30
    • 2012-12-25
    • 2011-01-31
    相关资源
    最近更新 更多