#!/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()  

  

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!