python smtp 发送图片 html格式的邮件 图片超过10K 邮件内容丢失
def sendMail(mail_user, to, content, subject="subject"):
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = mail_user
msg['To'] = to
html = """
<html>
<head></head>
<body>
<img src='cid:image1'>
</body>
</html>
"""
part2 = MIMEText(html, 'html', 'utf-8')
msg.attach(part2)
msgImage = MIMEImage(open('bgyz.jpg','rb').read())
msgImage.add_header('Content-ID', '<image1>')
msg.attach(msgImage)
print(msg)
server.sendmail(mail_user, to, msg.as_string())
运行效果:
只要图片大小超过10K就会出这此效果,小于10K则正常。
求大神指hkoh迷津~~~
小生在线跪等解答。
落跑的鞋子
9 years, 9 months ago