python之邮件操作
2016-03-31 22:58
483 查看
## 发送邮件(qq测试通过)
# -*- coding: cp936 -*- from email.Header import Header from email.MIMEText import MIMEText from email.MIMEMultipart import MIMEMultipart import smtplib, datetime msg = MIMEMultipart() att = MIMEText(open('f:\\fhf.txt', 'rb').read(), 'base64', 'gb2312') att["Content-Type"] = 'application/octet-stream' att["Content-Disposition"] = 'attachment; filename="fhf.txt"' msg.attach(att) msg['to'] = 'xx@qq.com' msg['from'] = 'yy@qq.com' msg['subject'] = Header('From FHF-PC(' + str(datetime.date.today()) + ')','gb2312') server = smtplib.SMTP('smtp.qq.com') server.login('xx','yy') error=server.sendmail(msg['from'], msg['to'],msg.as_string()) server.close if error == "{ }": print "Send Succed!" else: print "error::",error
相关文章推荐
- python语言学习1——初识python
- Python 标准库—— datetime(运行时间的判断)
- 《机器学习实战》——k-近邻算法Python实现问题记录
- python3中的mysql数据库操作
- python指南笔记(1)
- 升级pip8.1.1出现错误,因为安装目录有中文
- python 中的编码问题总结
- numpy.percentile
- Python for Data Analysis
- 借助 ptpython 三个命令实现终端下 PySpark 代码高亮和代码补全:
- 2016.3.31Python函数的参数
- 安装使用jupyter(原来的Ipython notebook)
- Python 中的列表排序函数
- python勿使用mutable值作为默认参数
- python运算符优先级
- python运算符基础实例
- 8.7 linecache--随机访问文本文件的行内容
- 8.6 tempfile--临时文件和目录处理
- 8.5 filecmp--文件和目录比较处理
- python中文乱码