首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用smtplib拒绝AOL邮件

使用smtplib拒绝AOL邮件
EN

Stack Overflow用户
提问于 2015-09-30 21:14:57
回答 2查看 1.6K关注 0票数 1

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

代码语言:javascript
复制
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.')

以下是对此错误的解释。

代码语言:javascript
复制
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)地址,在此调试消息之后,邮件被拒绝。

代码语言:javascript
复制
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'

以下是代码的简短版本:

代码语言:javascript
复制
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())

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

EN

回答 2

Stack Overflow用户

发布于 2015-09-30 21:45:39

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

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

票数 0
EN

Stack Overflow用户

发布于 2017-05-26 10:00:46

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

在您的特定情况下,可能有许多原因导致此5.2.1反弹。postmaster.aol.com站点提供了一些有用的工具来进行诊断,还提供了一些关于此特定错误消息的非常模糊的文档。在我的例子中,我最终嗅探了我的Thunderbird电子邮件客户端发送的SMTP消息和Python脚本的SMTP消息,并最终发现了其中的区别。

postmaster.aol.com文档:

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

AOL将不接受此邮件的传递

这是由于以下原因造成的永久性反弹:

  • RFC2822 From域与发送服务器的rDNS不匹配。
  • RFC2822 FROM地址没有A记录,不是有效的域。
  • IP信誉不佳,邮件发送到多个发件人地址的邮件标头中有多个From地址,IP信誉很差。

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

代码语言:javascript
复制
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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32867127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档