zoukankan      html  css  js  c++  java
  • 邮箱处理

    #excel报告
    def Email_excel(data):
        try:
            fromaddr = '1836166651@qq.com'
            password = 'rbekwgamdokabgjh'
            toaddrs = ['1836166651@qq.com']
            #toaddrs = value1
    
            content = '最新自动化用例执行结果已写入请查看附件与log日志'
            textApart = MIMEText(content)
    
            excelFile = '../testData/alltestcase.xlsx'
            excelApart = MIMEApplication(open(excelFile,'rb').read())
            excelApart.add_header('Content-Disposition', 'attachment', filename=excelFile)
    
            txtFile = '../log/%s.txt'%data
            txtApart = MIMEApplication(open(txtFile, 'rb').read())
            txtApart.add_header('Content-Disposition', 'attachment', filename=txtFile)
    
            m = MIMEMultipart('related')
            m.attach(textApart)
            m.attach(excelApart)
            m.attach(txtApart)
    
            m['Subject'] = '自动发送测试报告'
            m['From'] = '王大锤'
            m['to'] = '每日监控'
    
            server = smtplib.SMTP('smtp.qq.com')
            server.login(fromaddr, password)
            server.sendmail(fromaddr, toaddrs, m.as_string())
            print('自动化测试报告自动发送成功')
            #log.logger.info('自动化测试报告自动发送成功')
            server.quit()
        except smtplib.SMTPException as e:
            print('error:', e)  # 打印错误
            log.logger.info(e)
  • 相关阅读:
    centos7手动搭建redis集群
    Xshell突破四个窗口限制
    Redis官方集群规范
    Redis官方集群教程
    centos7 更新阿里YUM源
    gitlab配置ssh
    Java前端控制器模式~
    Java数据访问对象模式
    Java组合实体模式~
    Java业务代理模式~
  • 原文地址:https://www.cnblogs.com/xiaochuichui/p/13280915.html
Copyright © 2011-2022 走看看