python发送邮件
#!/usr/bin/env python # -*- coding: utf8 -*- import smtplib from email.mime.text import MIMEText textfile=‘sendmail.html‘ with open(textfile, ‘rb‘) as f: msg = MIMEText(fp.read(),‘html‘,‘utf8‘) msg.set_charset(‘utf8‘) me = ‘[email protected]‘ you = ‘[email protected]‘ msg[‘Subject‘] = ‘The contents of %s,中文标题‘ % textfile msg[‘From‘] = me msg[‘To‘] = you s = smtplib.SMTP(‘mx3.qq.com‘) #s.login() try: ret = s.sendmail(me, [you], msg.as_string()) except smtplib.SMTPRecipientsRefused, e: print e s.quit()
本文出自 “木子博客” 博客,请务必保留此出处http://ggbond.blog.51cto.com/8886865/1434019
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。