python 脚本发送邮件
2014-01-13 15:56
453 查看
#!/usr/bin/env python #coding: utf-8 import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText #import stmp_mail sender = 'hadoop520@126.com' receiver ='hello@126.com' subject = '数据测试' smtpserver = 'smtp.126.com' username = 'hadoop520' password = '111111' msgRoot = MIMEMultipart('related') msgRoot['Subject'] = 'test message' #构造附件 att = MIMEText(open('/apps/aspbi/shenshuxin/1.csv', 'rb').read(), 'base64', 'utf-8') att["Content-Type"] = 'application/octet-stream' att["Content-Disposition"] = 'attachment; filename="数据.csv"' msgRoot.attach(att) smtp = smtplib.SMTP() smtp.connect('smtp.126.com') smtp.login(username, password) smtp.sendmail(sender, receiver, msgRoot.as_string()) smtp.quit()
相关文章推荐
- Python 程序员应该知道的 10 个库
- Python 注意
- python与复杂科学(2013-09-16 15:28:21)转载▼
- python 得进化
- python 字符串
- commands 模块 分类: python 小练习 python Module 2014-01-13 14:27 392人阅读 评论(0) 收藏
- Python:Error: Inconsistent indentation detected!解决办法
- python入门指引
- Python 操作 MySQL
- Python+BeautifulSoup抓取暴走漫画页面图片
- 在目录下找出特定格式的文件 python
- Python学习6:动态类型与共享引用
- mysql-python安装 _mysql.c:602: error: expected expression before ‘)’ token
- 用python来过滤无效用户名或密码
- python 容器排序
- 转python编码问题
- python的os.urandom 的用途
- Eclipse按装Python开发环境
- yield生成器对象返回Fiabs元素 分类: python 小练习 python基础学习 2014-01-13 10:28 193人阅读 评论(0) 收藏
- 执行python程序