源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

python 七种邮件内容发送方法实例

  • 时间:2021-02-27 10:41 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:python 七种邮件内容发送方法实例
[b]一、文件形式的邮件 [/b]
[url=http://www.python.org]   """ # Record the MIME types of both parts - text/plain and text/html. part1 = MIMEText(text, 'plain') part2 = MIMEText(html, 'html') # Attach parts into message container. # According to RFC 2046, the last part of a multipart message, in this case # the HTML message, is best and preferred. msg.attach(part1) msg.attach(part2) #构造附件 att = MIMEText(open('h:\\python\\1.jpg', 'rb').read(), 'base64', 'utf-8') att["Content-Type"] = 'application/octet-stream' att["Content-Disposition"] = 'attachment; filename="1.jpg"' msg.attach(att) smtp = smtplib.SMTP() smtp.connect('smtp.163.com') smtp.login(username, password) smtp.sendmail(sender, receiver, msg.as_string()) smtp.quit()
[b]七、基于SSL的邮件[/b]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部