如何用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())

 

你可能感兴趣的:(html,python)