以下脚本是用在python3 发邮件的脚本。脚本出处
https://www.cnblogs.com/jjzd/p/6617499.html
-
#!/usr/bin/python3
-
# coding:utf-8
-
-
import sys
-
from email.mime.text import MIMEText
-
import smtplib
-
-
-
mail_host = 'smtp.126.com'
-
mail_user = 'xuekai20080901'
-
mail_pass = '*****'
-
mail_postfix = '126.com'
-
-
-
def send_mail(to, subject, content):
-
-
me = "zabbix 监控告警平台"+"<"+mail_user+"@"+mail_postfix+">"
-
msg = MIMEText(content, 'plain', 'utf-8')
-
msg['Subject'] = subject
-
msg['From'] = me
-
msg['To'] = to
-
-
try:
-
s = smtplib.SMTP(mail_host)
-
s.set_debuglevel(1)
-
s.login(mail_user, mail_pass)
-
s.sendmail(me, [to], msg.as_string())
-
s.close()
-
-
except Exception as e:
-
print(str(e))
-
-
-
if __name__ == "__main__":
-
send_mail(sys.argv[1], sys.argv[2], sys.argv[3])
阅读(1481) | 评论(0) | 转发(0) |