发布时间:2019-09-08 09:12:32编辑:auto阅读(2057)
python发送抄送邮件
sendemial.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.mime.multipart import MIMEMultipart
import time
import os
mail_host="smtp.miao.cn"
mail_user="wei@miao.cn"
mail_pass="qwe"
sslPort="465"
time1=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
sender = 'wei@miao.cn'
to_reciver = ['wei@miao.cn']
cc_reciver =[ 'dongya@126.com']
reciver = to_reciver + cc_reciver
message = MIMEText('dddddddddd', _subtype='html', _charset='utf-8')
message['From'] = sender
message['To'] = ";".join(to_reciver)
message['Cc'] = ";".join(cc_reciver)
subject ='接口自动化测试报告'+'-'+time1
message['Subject'] = Header(subject, 'utf-8')
try:
smtpObj = smtplib.SMTP_SSL(mail_host,sslPort)
smtpObj.ehlo()
smtpObj.login(mail_user,mail_pass)
smtpObj.sendmail(sender,reciver, message.as_string())
print ("邮件发送成功")
except Exception as n:
print ("Error: 无法发送邮件")
print(n)
上一篇: 利用cython将python转为c代码
下一篇: python 的跨包引用
48820
47876
38655
35824
30244
26993
26037
20865
20658
19026
446°
531°
551°
562°
543°
528°
595°
659°
781°
844°