python实现html格式的数据报邮件(qq)

[root@www smtplib]# cat qq_mail_html.py

!/usr/bin/env python

import smtplib
from email.mime.text import MIMEText #??MIMEText?

HOST = "smtp.163.com"
SUBJECT = "Website traffic data tables"
TO = "[email protected]"
FROM = "[email protected]"
msg = MIMEText("""

Website data more>>
1)day_traffic:152433 traffic:23651 page_traffic:45123 click:545122 data_flow:504Mb
2)Status code information
500:105 404:3264 503:214
3)user information
IE:50% firefox:10% chrome:30% other:10%
4)page information
/index.php 42153
/view.php 21451
/login.php 5112
""","html","utf-8")

msg['Subject'] = SUBJECT
msg['From']=FROM
msg['To']=TO
try:
server = smtplib.SMTP()
server.connect(HOST,"25")
server.starttls()
server.login("[email protected]","kptgpcamuyzxodvo")
server.sendmail(FROM, TO, msg.as_string())
server.quit()
print "send yes!"
except Exception, e:
print "lose:"+str(e)
[root@www smtplib]#

测试:

[root@www smtplib]# python qq_mail_html.py
send yes!
[root@www smtplib]#

下面连接 有图
http://9399369.blog.51cto.com/9389369/1735319

你可能感兴趣的:(python实现html格式的数据报邮件(qq))