2017-07-17 17:25:47 236次浏览
#coding: utf-8
import smtplib
import sys
from email.mime.text import MIMEText
from email.header import Header
def sendmail(username,password,receiver,subject,text):
sender = username
smtp = smtplib.SMTP()
smtp.connect('smtp.126.com')
smtp.login(username, password)
msg = MIMEText(text,'plain','utf-8')#中文需参数‘utf-8’,单字节字符不需要
msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = '名称<ituser@126.com>' #在收件箱列表显示:名称
for peple in receiver:
smtp.sendmail(sender, peple, msg.as_string())
smtp.quit()
if __name__ == '__main__':
argv = sys.argv
sender = 'ituser@126.com' #发件人
receiver = ('#########','########') #收件人
subject = '########' #邮件标题
text = '内容'
username = 'ituser@126.com' #邮箱账号
password = '*****' #邮箱授权码
sendmail(username,password,receiver,subject,text)
所有内容来及个人经验和互联网摘取,如有雷同纯属巧合,如有冒犯,欢迎留言,分享即快乐,感谢互联网中每一位懂得分享的ituser!QQ群:127331971(备注:ituser.cn)