当前位置: 移动技术网 > IT编程>脚本编程>Python > python smtplib发email

python smtplib发email

2019年04月14日  | 移动技术网IT编程  | 我要评论

哥斯拉复活国语,荒川洋子,篮球王子与笨猪公主

#!/usr/bin/env python

#coding: utf-8  



import smtplib  

from email.mime.text import mimetext  

from email.header import header  

  

sender = 'tom'  

receiver = ['john@sina.com', 'lili@163.com']  

subject = 'python email test'  

smtpserver = 'smtp.sina.com'  

username = 'yourusername'  

password = 'yourpassword'  



msg = mimetext('你好','text','utf-8')#中文需参数‘utf-8’,单字节字符不需要  

msg['subject'] = header(subject, 'utf-8')  



smtp = smtplib.smtp()  

smtp.connect(smtpserver)  

smtp.login(username, password)  

smtp.sendmail(sender, receiver, msg.as_string())  

smtp.quit()  

  

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网