Python邮件脚本

 1 def sendmail():
 2     import  smtplib
 3     from email.mime.text import MIMEText
 4     from email.utils import formataddr
 5 
 6     msg = MIMEText('邮件内容','plain','utf-8')
 7     msg['From'] = formataddr(['bob','liangml0418@163.com'])
 8     msg['To'] = formataddr(["走人",'1729562020@qq.com'])
 9     msg['Subject'] = '主题'
10 
11     server = smtplib.SMTP('smtp.163.com',25)
12     server.login('liangml0418@163.com','邮箱密码')
13     server.sendmail('liangml0418@163.com',['1729232020@qq.com'],msg.as_string())
14     server.quit()
15 
16 sendmail()

 

posted @ 2016-10-12 17:02  Callum  阅读(178)  评论(0编辑  收藏  举报