hao0089 发表于 2017-5-7 09:02:13

如何用python发送html格式的邮件

import smtplib
from email.MIMEText import MIMEText
smtp_server = smtplib.SMTP(smtp_host)
html='<html><body>hello world</body></html>'
msg = MIMEText(html, 'html')
msg['From'] = sender
msg['To'] = recipient
msg['Subject'] = 'hello'
smtp_server.set_debuglevel(1) #output debug log
smtp_server.sendmail(sender, recipient, msg.as_string())

 
页: [1]
查看完整版本: 如何用python发送html格式的邮件