首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

python利用smtp来发送邮件(带附件

运行环境:python2.7,python3.x的话,把代码中的中文的字符前的u去掉就好,这是2与3基本的区别 # -*- coding: utf-8 -*- import smtplib import...,*****是发送来源的邮箱,xxx是发送邮件时候的标题, To = " ###"  # 接受邮件的邮箱 file_name = "***"   # 附件名(带路径) server = smtplib.SMTP_SSL...-8859-1,utf-8" main_msg.attach(text_msg) # 设置有中文的字符串,在微软的outlook中乱码,所以才有了上面对中文的设置 # 构造MIMEBase对象做为文件附件内容并附加到根容器... subtype) file_msg.set_payload(data.read()) data.close() email.Encoders.encode_base64(file_msg)  # 把附件编码...## 设置附件头 basename = os.path.basename(file_name) file_msg.add_header('Content-Disposition', 'attachment

89840

python利用smtp来发送邮件(带附件

V站笔记 运行环境:python2.7,python3.x的话,把代码中的中文的字符前的u去掉就好,这是2与3基本的区别 # -*- coding: utf-8 -*- import smtplib...,*****是发送来源的邮箱,xxx是发送邮件时候的标题, To = " ###"  # 接受邮件的邮箱 file_name = "***"   # 附件名(带路径) server = smtplib.SMTP_SSL...-8859-1,utf-8" main_msg.attach(text_msg) # 设置有中文的字符串,在微软的outlook中乱码,所以才有了上面对中文的设置 # 构造MIMEBase对象做为文件附件内容并附加到根容器... subtype) file_msg.set_payload(data.read()) data.close() email.Encoders.encode_base64(file_msg)  # 把附件编码...## 设置附件头 basename = os.path.basename(file_name) file_msg.add_header('Content-Disposition', 'attachment

1.2K40
领券