1

我正在使用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 帐户成功发送了相同的电子邮件,没有任何问题吗?

4

2 回答 2

0

I guess that AOL doesn't allow relay access by default or you have not configured it manually. The error you get says that aol doesn't have recipient you want to send message. In this case if you want to send email to gmail account try to connect to gmail SMPT server instead of AOL.

Change smpt server to gmail-smtp-in.l.google.com for example and turn off authentication.

于 2015-09-30T13:45:39.363 回答
0

我自己是5.2.1 : AOL will not accept delivery of this message.从 AOL SMTP 中继遇到的。我最终需要的是 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()
于 2017-05-26T02:00:46.150 回答