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())
如何用python发送html格式的邮件
最新推荐文章于 2022-11-20 21:11:54 发布
本文介绍了一种使用Python发送带HTML格式邮件的方法。通过smtplib模块连接SMTP服务器,并利用email.mime.text.MIMEText构造HTML内容,实现了从指定发件人向收件人发送包含简单问候的HTML邮件。
1748

被折叠的 条评论
为什么被折叠?



