赞
踩
使用python发送带图片的邮件
MIMEMultipart('related')
msgHtmlImg = '<img src="cid:image{count}"><br>'
MIMEText(msgHtmlImg, 'html')
fp = open(imgpath, 'rb')
msgImage = MIMEImage(fp.read())
fp.close()
# Define the image's ID as referenced above
msgImage.add_header('Content-ID', '<image{count}>'.format(count=i))
msgRoot.attach(msgImage)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import smtplib
import os
import logging
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
logger = logging.getLogger("django")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。