zabbix sendmail(python)
#!/usr/bin/python #coding:utf-8 import smtplib from email.mime.text import MIMEText import sys mail_host = ‘smtp.163.com‘ mail_user = ‘username‘ mail_pass = ‘password‘ mail_postfix = ‘163.com‘ 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() returnTrue except Exception,e: print str(e) returnFalse if __name__ == "__main__": send_mail(sys.argv[1], sys.argv[2], sys.argv[3])
本文出自 “muzinan的技术博客” 博客,谢绝转载!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。