Python 发送带附件的email详解编程语言
2023-06-13 09:20:23 时间
from email.MIMEText import MIMEText from email.MIMEMultipart import MIMEMultipart import smtplib mail_host = smtp.126.com mail_user = [email protected] mail_pwd = xx mail_to = [email protected]
att = MIMEText(open(d://a.txt,rb).read(),base64,gb2312) att["Content-Type"] = application/octet-stream att["Content-Disposition"] = attachment;filename="hello.txt" msg.attach(att) message = content part body = MIMEText(message) msg.attach(body) msg[To] = mail_to msg[from] = mail_user msg[subject] = this is a python test mail try: s = smtplib.SMTP() s.connect(mail_host) s.login(mail_user,mail_pwd) s.sendmail(mail_user,mail_to,msg.as_string()) s.close() print success except Exception,e: print e
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8197.html
cjavapython相关文章
- python中矩阵的转置怎么写_Python 矩阵转置的几种方法小结
- python海龟作图红绿灯_海龟作图—用Python绘图
- python生成器详解_Python 生成器
- 【测试开发】python系列教程:函数(三)
- Python快速多线程ping实现详解编程语言
- python多线程多队列(BeautifulSoup网络爬虫)详解编程语言
- python转换字符串为datetime类型详解编程语言
- 计算时间差,时间加减运算python代码详解编程语言
- python操作mysql数据库代码详解编程语言
- Python实现 深度优先算法生成迷宫详解编程语言
- Python使用win32api获取DLL和EXE文件版本号详解编程语言
- Python电子邮件——学习笔记详解编程语言
- python多线程详解编程语言
- Python_Day34_Socket模块2和黏包现象详解编程语言
- python常见释疑(有别于报错)(不定时更新)详解编程语言
- Appium环境搭建python篇(mac系统)详解编程语言
- 使用python做简单的接口性能测试详解编程语言
- python学习 异常详解编程语言
- python:订制类详解编程语言
- python: partical function 偏函数详解编程语言
- python模块之time模块详解编程语言
- Python爬取MySQL数据,助力数据分析(python读取mysql数据)