首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

运用python发送html格式的email

2012-12-28 
使用python发送html格式的email和大伙分享一个使用python发送html格式的email的代码。 我用在我的软件的bug

使用python发送html格式的email
和大伙分享一个使用python发送html格式的email的代码。 我用在我的软件的bug提交中。代码如下。

请将代码中的email和密码替换成您的email和密码。

# -*- coding: cp936 -*-'''send email via gmail,support html emailBy Jibo Hehejibo@ueseo.org'''import smtplibmsg = """From: From 何吉波 <hejibo@ueseo.org>To: To UESEO <contact@ueseo.org>MIME-Version: 1.0Content-type: text/htmlSubject: SMTP HTML e-mail testThis is an e-mail message to be sent in HTML format<b>This is HTML message.</b><h1>This is headline.</h1><h2><a href="http://www.ueseo.org">优异搜索</a></h2>"""server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587server.ehlo()server.starttls()server.ehlo()server.login('hejibo@ueseo.org','[b]XXXXXX[/b][color=red][/color]')#请替换成您的email和密码server.sendmail('hejibo@ueseo.org','contact@ueseo.org',msg)server.close()

热点排行