首页 > 编程语言 > 详细

python发送邮件

时间:2014-07-04 06:42:04      阅读:503      评论:0      收藏:0      [点我收藏+]
#!/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 = ‘xxx@163.com‘  
you = ‘xxxx@qq.com‘  
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

python发送邮件,布布扣,bubuko.com

python发送邮件

原文:http://ggbond.blog.51cto.com/8886865/1434019

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!