邮件反馈脚本:
def sendOutEmail163(str):
#配置发件人以及收件人
sender= 'zy********@163.com'
aaron= 'aa********.co'
eric= 'l********@shiyi.co'
receivers= (aaron,eric)
mail_host= 'smtp.163.com'
mail_user= sender
mail_pass= 'z**************'
#编写邮件具体内容
content= str
message= MIMEText(content,'plain','utf-8')
message['From']= 'zyou*********@163.com'
message['To']= ','.join(receivers)# 这里必须要把多个邮箱按照逗号拼接为字符串
subject= '接口自动化脚本异常反馈'
message['Subject']= Header(subject,'utf-8')
#邮件发送
try:
smtpObj= smtplib.SMTP()
smtpObj.connect(mail_host,25)# 25 为 SMTP 端口号
smtpObj.login(mail_user,mail_pass)
smtpObj.sendmail(sender, receivers, message.as_string())
print("邮件发送成功!")
except smtplib.SMTPException:
print("邮件发送失败!")
网友评论