首页 > 编程语言 > 详细

selenium+python smtp邮件

时间:2017-05-17 13:06:43      阅读:268      评论:0      收藏:0      [点我收藏+]

#code:utf-8

import smtplib from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart

from email.header import Header

smtpserver = ‘smtp.163.com‘

smtp_user = ‘*******‘

smtp_pass = ‘*******‘

from_addr=‘**********@163.com‘

to_addr= ‘********@qq.com‘

subject = ‘休假申请‘

#message = MIMEMultipart()

message = MIMEText(‘这是今天的休假申请‘,‘plain‘,‘utf-8‘)

message[‘Subject‘] = Header(subject,‘utf-8‘)

message[‘From‘] = from_addr

message[‘To‘] = to_addr

#注释部分为带附件的代码

#message.attach(message_text)

#att1=MIMEText(open(‘test.txt‘,‘rb‘).read(),‘base64‘,‘utf-8‘)

#att1[‘Content-Type‘] = ‘application/octet-stream‘

#att1[‘Content-Disposition‘] = ‘attachment:filename="test.txt"‘

#message.attach(att1)

sm=smtplib.SMTP()

sm.connect(smtpserver,25)

sm.login(smtp_user,smtp_pass)

sm.sendmail(from_addr,to_addr,message.as_string())

sm.quit()

selenium+python smtp邮件

原文:http://www.cnblogs.com/youngyang/p/6866557.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!