使用python smtplib库发邮件添加cc,bcc
2019-07-23 来源:open-open
[Python]代码
# -*- coding: cp936 -*-
import smtplib
from email.mime.text import MIMEText
mail_host = 'smtp.126.com'
mail_user = 'xxx@126.com'
mail_pwd = 'hellopwd'
mail_to = 'xxao@gmail.com'
mail_cc = 'xx@xx.com'
mail_bcc = 'xx@qq.com'
content = 'this is a mail sent with python'
#表头信息
msg = MIMEText(content)
msg['From'] = mail_user
msg['Subject'] = 'this is a python test mail'
msg['To'] = mail_to
msg['Cc'] = mail_cc
msg['Bcc'] = mail_bcc
try:
s = smtplib.SMTP()
s.connect(mail_host)
#login
s.login(mail_user,mail_pwd)
#send mail
s.sendmail(mail_user,[mail_to,mail_cc,mail_bcc],msg.as_string())
s.close()
print 'success'
except Exception ,e:
print e
标签: [db:TAGG]
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:php异步处理类
下一篇:分享一个PHP加密解密的类
最新资讯
热门推荐