TA的每日心情 | 开心 2019-1-20 18:12 |
---|
签到天数: 101 天 连续签到: 1 天 [LV.6]测试旅长
|
请教一下各位大神,python中先用htmlTestRunner生成了自动化测试报告,但是用SMTPlib来发送测试报告一直发送不成功,也没有任何报错;
如下是我编写的测试代码,邮箱和密码都是正确的,这里我只是写成了test了
#coding=utf-8
import smtplib ,time
from email.mime.text import MIMEText
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
f=open("result.html",'rb')
mail_body=f.read()
f.close()
msg =MIMEMultipart()
msg['from']="test@sina.com"
msg['to']="Test@163.com"
msg['Subject']= u"自动化测试报告"
htm = MIMEText(mail_body,'html','utf-8')
print(mail_body)
msg.attach(htm)
smtp = smtplib.SMTP()
msg['date']=time.strftime('%a, %d %b %Y%H:%M:%S %z')
smtp=smtplib.SMTP()
smtp.connect('smtp.sina.com')
smtp.login(msg['from'],'password')
smtp.sendmail(msg['from'],msg['to'],msg.as_string())
smtp.quit()
|
|