码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix邮件报警脚本

时间:2016-08-20 08:58:46      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

#!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
mail_host = ‘smtp.exmail.qq.com‘
mail_user = ‘邮箱全称‘
mail_pass = ‘密码‘
mail_postfix = ‘域名‘
def send_mail(to_list,subject,content):
me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
msg = MIMEText(content)
msg[‘Subject‘] = subject
msg[‘From‘] = me
msg[‘to‘] = to_list
try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me,to_list,msg.as_string())
s.close()
return True
except Exception,e:
print str(e)
return False
#if __name__ == "__main__":
send_mail(sys.argv[1], sys.argv[2], sys.argv[3])

  

zabbix邮件报警脚本

标签:

原文地址:http://www.cnblogs.com/xmzncc/p/5789579.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!