发送测试报告

只谈情不闲聊 提交于 2019-12-06 14:34:22
import smtplibfrom email.mime.text import MIMETextimport osdef send_report(report):    sender = "8000@sfmail.sf-express.com"    receiver = "8000@sfmail.sf-express.com"    username = sender    password = "123456"    smtpsenderserver = "lsmtp.sf-express.com"    with open(report,"rb") as f:        sendmessage = f.read()    content = MIMEText(sendmessage, _subtype="html", _charset="utf-8")    content["from"] = sender    content["to"] = receiver    content["subject"] = u"测试报告标题"    smtp = smtplib.SMTP()  # 初始化邮箱服务,实例化    smtp.connect(smtpsenderserver,"25")    smtp.login(username,password)    smtp.sendmail(sender,receiver,content.as_string())    smtp.close()def findnewreport():    report_path = r"C:\Users\80002907\PycharmProjects\xuexi1128\1128\report"    listreport = os.listdir(report_path)    listreport.sort(key=lambda f:os.path.getmtime(report_path+"\\"+f))    newreport = listreport[-1]    send_report(newreport)findnewreport()


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!