python官方示例发送带附件邮件,python官方示例附件,下面的示例代码发送带图片
python官方示例发送带附件邮件,python官方示例附件,下面的示例代码发送带图片
下面的示例代码发送带图片附件的邮件
# 导入smtplib包import smtplib# Here are the email package modules we'll needfrom email.mime.image import MIMEImagefrom email.mime.multipart import MIMEMultipartCOMMASPACE = ', '# Create the container (outer) email message.msg = MIMEMultipart()msg['Subject'] = 'Our family reunion'# me == the sender's email address# family = the list of all recipients' email addressesmsg['From'] = memsg['To'] = COMMASPACE.join(family)msg.preamble = 'Our family reunion'# Assume we know that the image files are all in PNG formatfor file in pngfiles: # Open the files in binary mode. Let the MIMEImage class automatically # guess the specific image type. fp = open(file, 'rb') #初始化附件对象 img = MIMEImage(fp.read()) fp.close() #添加附件到msg msg.attach(img)# 使用SMTP server发送邮件s = smtplib.SMTP('localhost')s.sendmail(me, family, msg.as_string())s.quit()
相关内容
- python发送html格式邮件,python发送html,#!/usr/bin/e
- BeautifulSoup解析人人好友状态,beautifulsoup解析,#!/usr/bi
- 定时关机神器,定时关机神,有了它,你以后再也不为深
- 简单SVM分类器的开源实现,核心代码150行,svm150行,一个
- python在linux系统下获取系统内存使用情况,pythonlinux,"
- 抓取乌云会员信息,抓取会员信息,抓取乌云网站白帽子
- 元类 metaclass,metaclass,python 可以生成任
- python 获取ip代理地址,python获取ip代理,# -*- coding
- 删除windows垃圾文件,删除windows垃圾,#coding:utf-
- 一个简单的类封装,提供简单的web操作,类封装web操作
评论关闭