zoukankan      html  css  js  c++  java
  • python标准库smtplib在UI自动化测试中的实现-邮件发送测试报告

    
    

    import smtplib
    from email.mime.text import MIMEText
    from email.mime.multipart import MIMEMultipart


    def
    send_email(receiver): ''' 发送最新的测试报告 :return: ''' # 打开测试报告 with open(reportfile, "rb") as f: email_body = f.read() # 定义邮件内容 message = MIMEMultipart() body = MIMEText(_text=test, _subtype='html', _charset='utf-8') message['Subject'] = u"多媒体自动化测试报告_{}".format(times) message["from"] = sender message["to"] = receiver message.attach(body) # 添加附件 attachment = MIMEText(_text=email_body, _subtype='base64', _charset='utf-8)') attachment["Content-Type"] = "application/octet-stream" attachment["Content-Disposition"] = 'attachment; filename= "report.html"' message.attach(attachment) try: smtp = smtplib.SMTP_SSL(smtpserver, port) except: smtp = smtplib.SMTP() smtp.connect(smtpserver, port) # 发送邮件 smtp.login(sender, psw) smtp.sendmail(sender, receiver, message.as_string()) # 关闭邮件 smtp.quit()
    没伞的孩子,就要学会在雨中奔跑!
  • 相关阅读:
    window.onload 、body.onload 以及 jQuery 等dom加载完成后执行脚本的区别
    HTML5事件-pageshow 和 pagehide
    动态加载script 和 link
    递归 recursive
    HTML5事件-自定义右键菜单
    left与margin-left区别
    偏移量、客户区、滚动大小
    屏幕适配
    KVC和KVO
    HUD总结
  • 原文地址:https://www.cnblogs.com/mikigo/p/13226004.html
Copyright © 2011-2022 走看看