标签:
1.自动化测试中,调用邮件模块自动发送邮件时,运行脚本报错:
smtplib.SMTPDataError: (554, ‘DT:SPM 126 smtp5,jtKowAD3MJz2c1JXLcK2AA--.52114S2 1465021431,please see http://mail.163.com/help/help_spam_16.htm?ip=123.114.121.110&hostid=smtp5&time=1465021431‘)
2.解决方法(这里已python为例):
#定义发送邮件
def send_mail(file_new):
f = open(file_new, ‘rb‘)
mail_body = f.read()
f.close()
msg = MIMEText(mail_body, ‘html‘, ‘utf-8‘)
msg = MIMEText(‘请查看附件内容!‘,‘plain‘,‘utf-8‘)
msg[‘Subject‘] = Header("自动化测试报告", ‘utf-8‘)
#报错原因是因为“发件人和收件人参数没有进行定义
msg[‘from‘] = ‘test_bug@126.com‘
msg[‘to‘] = ‘testyao@163.com‘
smtp = smtplib.SMTP()
smtp.connect("smtp.126.com")
smtp.login("test_bug@126.com", "登录密码")
smtp.sendmail("test_bug@126.com","testyao@163.com", msg.as_string())
smtp.quit()
print(‘邮件发送成功email has send out !‘)
3.利用此种方法(绿色代码部分)即可解决相关邮箱的554, ‘DT:SPM的错误。
smtplib.SMTPDataError: (554, 'DT:SPM 126 smtp5错误解决办法
标签:
原文地址:http://www.cnblogs.com/testyao/p/5558810.html