#!/usr/bin/env python #coding: utf-8 import smtplib import sys,os from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.p_w_picpath import MIMEImage def sendmail(receiver,subject,content): sender = 'monitor@company.com' receiver = sys.argv[1] subject = sys.argv[2] smtpserver = 'smtp.exmail.qq.com' username = 'monitor@company.com' password = 'monitor_password' msgRoot = MIMEMultipart('related') msgRoot['Subject'] = subject msgRoot['From'] = '<monitor@company.com>' msgRoot['To'] = receiver msgText = MIMEText(content) #msgText = MIMEText(content,'html','utf-8') msgRoot.attach(msgText) smtp = smtplib.SMTP() smtp.connect(smtpserver) smtp.login(username, password) smtp.sendmail(sender, receiver, msgRoot.as_string()) smtp.quit() if __name__ == '__main__': if len(sys.argv) < 3: print '%s addres subject msg' % sys.argv[0] sys.exit() sendmail(sys.argv[1],sys.argv[2],sys.argv[3])
zabbix发送邮件py脚本
精选 转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
zabbix 发送邮件配置
对应关系如图
zabbix