qq的服务器性能,python实现图文格式的服务器性能报表邮件(qq)

[root@www smtplib]# cat qq_mail_tupian.py

#!/usr/bin/env python

import smtplib

from email.mime.multipart import MIMEMultipart

from email.mime.text import MIMEText

from email.mime.p_w_picpath import MIMEImage

HOST = "smtp.163.com"

SUBJECT = "Business performance data report"

TO = "961769710@qq.com"

FROM = "15517707935@163.com"

def addimg(src,imgid):

fp = open(src, 'rb')

msgImage = MIMEImage(fp.read())

fp.close()

msgImage.add_header('Content-ID', imgid)

return msgImage

msg = MIMEMultipart('related')

msgtext = MIMEText("""

*Website performance data  more>>

        

        

        

        

""","html","utf-8")

msg.attach(msgtext)

msg.attach(addimg("img/bytes_io.png","io"))

msg.attach(addimg("img/myisam_key_hit.png","key_hit"))

msg.attach(addimg("img/os_mem.png","men"))

msg.attach(addimg("img/os_swap.png","swap"))

msg['Subject'] = SUBJECT    #subject

msg['From']=FROM

msg['To']=TO

try:

server = smtplib.SMTP()    #create

server.connect(HOST,"25")    #by connect connect  smtp host

server.starttls()    #ssl  safe

server.login("15517707935@163.com","kptgpcamuyzxodvo")    #login

server.sendmail(FROM, TO, msg.as_string())    #send mail

server.quit()    #quit smtp connect

print "send yes"

except Exception, e:

print "lose:"+str(e)

[root@www smtplib]#

测试:

[root@www smtplib]# python qq_mail_tupian.py

send yes

[root@www smtplib]#

f5bf2f820b4491af47e0e873a80365c2.png

20543e6946599dde9ca2221408be2bc8.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值