标签:中心 code com .text 分享图片 邮箱 python zabbix str
配置过程;配置主动和被动模式是在监控项里配置,
操作步骤:
注释:zabbix客户端为被动模式,zabbix客户端(主动式)为主动模式
#!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
mail_host = ‘smtp.163.com‘
mail_user = ‘abcdefg@xx.com‘
mail_pass = ‘1111111‘
mail_postfix = ‘163.com‘
def send_mail(to_list,subject,content):
me = "zabbix 监控告警平台"+"<"+mail_user+"@"+mail_postfix+">"
msg = MIMEText(content, ‘plain‘, ‘utf-8‘)
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])
标签:中心 code com .text 分享图片 邮箱 python zabbix str
原文地址:http://blog.51cto.com/13451715/2335764