Commit f5aa6f10 by zhangchunyao

Delete Mail.py

parent bbcfd774
#coding=utf-8
import smtplib
from email.mime.text import MIMEText #MIMRText()定义邮件正文
from email.mime.multipart import MIMEMultipart #MIMEMulipart模块构造带附
def sendResultMail(smtpSever,sendUser,sendPwd,recvUser,reportName):
#发送邮件的服务器
#smtpserver = 'smtp.sina.com'
smtpserver =smtpSever
#发送邮件用户和密码
#user ="xxx@sina.com"
#password = "xxx"
user = sendUser
password = sendPwd
#发送者
#sender = "xxx@sina.com"
sender = sendUser
#接收者
#receiver = "1xxx@qq.com"
receiver = recvUser
#邮件主题
subject = "接口自动化执行结果"
#发送附件
sendfile = open(reportName,"rb").read()
att = MIMEText(sendfile,"base64","utf-8")
att["Content-Type"] = "application/octet-stream"
att["Content-Disposition"] = "attachment;filename = 'autoInterfaceResult.html'"
#msghtml = MIMEText('<h1 style="color:red;font-size:100px">各位好,附件为接口自动化测试详细结果,请查阅</h1><img src="cid:small">', 'html', 'utf-8')
msghtml = MIMEText('<h2 style="color:red;font-size:50px">各位好,附件为接口自动化测试详细结果,请查阅</h2>', 'html', 'utf-8')
#msg = MIMEText('接口自动化测试结果', 'plain', 'utf-8')
msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = subject
msgRoot['from'] = "测试服务器"
msgRoot['To'] = receiver
msgRoot.attach(att)
msgRoot.attach(msghtml)
#msgRoot.attach(msg)
smtp = smtplib.SMTP()
smtp.connect(smtpserver)
smtp.login(user,password)
smtp.sendmail(sender,receiver,msgRoot.as_string())
smtp.quit()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment