标签:zabbix 报警脚本 发送邮件脚本 python发邮件脚本
最近发现zabbix发送邮件的shell脚本经常被反垃圾,所以特意写了一个python脚本调用外部邮箱
#!/usr/bin/python #coding: utf-8 import smtplib from email.mime.text import MIMEText from email.header import Header import sys from email.Utils import COMMASPACE receiver = sys.argv[1] subject = sys.argv[2] txbody = sys.argv[3] smtpserver = ‘smtp.qq.com‘ username = ‘zabbix@qq.com‘ password = ‘xxxxxxxx‘ sender = username msg = MIMEText(sys.argv[3],‘html‘,‘utf-8‘) msg[‘Subject‘] = Header(subject, ‘utf-8‘) msg[‘From‘] = username msg[‘To‘] = receiver smtp = smtplib.SMTP() smtp.connect(smtpserver) smtp.login(username, password) smtp.starttls() smtp.sendmail(msg[‘From‘], msg[‘To‘], msg.as_string()) smtp.quit()
本文出自 “nginxs小白” 博客,请务必保留此出处http://nginxs.blog.51cto.com/4676810/1695855
标签:zabbix 报警脚本 发送邮件脚本 python发邮件脚本
原文地址:http://nginxs.blog.51cto.com/4676810/1695855