发布时间:2019-08-28 09:09:34编辑:auto阅读(1999)
!/usr/bin/python
coding: utf-8
import smtplib
import sys
from email.mime.text import MIMEText
_user = "12345678@qq.com"
_pwd = "授权码"
_to = "123456789@163.com"
def send_mail(to,subject,contain):
msg = MIMEText(contain)
msg["Subject"] = subject
msg["From"] = _user
msg["To"] = to
try:
s = smtplib.SMTP_SSL("smtp.qq.com", 465)
s.login(_user, _pwd)
s.sendmail(_user, to, msg.as_string())
s.quit()
with open('/tmp/zabbix.log', 'w') as f:
f.write("%s\n%s\n%s\n"%(to,subject,contain))
print "Success!"
except smtplib.SMTPException,e:
print "Falied,%s"%e
if name == "main":
send_mail(sys.argv[1], sys.argv[2], sys.argv[3])
上一篇: CentOS 6升级默认python版本
下一篇: python os, os.path和s
51598
51188
41692
38451
32936
29923
28627
23593
23524
21871
2033°
2742°
2288°
2217°
2694°
2243°
2991°
4933°
4790°
3407°