python模块整理17-mail-smtplib

#!/usr/bin/env python
import subprocess
import smtplib
import string

p=subprocess.Popen("df -h",shell=True,stdout=subprocess.PIPE)
MSG=p.stdout.read()
FROM="root@localhost"
TO="root@localhost"
SUBJECT="DISK Usage Report"
msg=string.join(("From:%s" % FROM,"TO:%s" % TO,"Subject:%s" % SUBJECT,"",MSG),"\r\n")
#print msg

s=smtplib.SMTP("localhost")
s.set_debuglevel(1)
s.sendmail(FROM,TO,msg)
s.quit()

posted on 2012-11-05 14:41  @Jin  阅读(182)  评论(0编辑  收藏  举报

导航