好吧,我承认官网的邮件配置教程我又没看懂,这里记录下我的配置方法
[root@HE3]# vi /usr/local/lepus/test_send_mail.py
#!/usr/bin/envpython # -*- coding: utf8-*- from datetime import* import sys path='./include' sys.path.insert(0,path) import functions asfunc #mail_to_list = func.get_option('mail_to_list') send_mail_to_list =func.get_option('send_mail_to_list') mailto_list=send_mail_to_list.split(';') result =func.send_mail(mailto_list," I hope you can learn","BeautifulDay") print result if result: send_mail_status = "success" else: send_mail_status = "fail" print"send_mail_status:"+send_mail_status
注释掉原有的mail_to_list,添加一行send_mail_to_list =func.get_option('send_mail_to_list')
原有的mailto_list=mail_to_list.split(';')改为mailto_list=send_mail_to_list.split(';')
去申请一个新的126邮箱,选择设置-POP3/SMTP/IMAP-客户端授权密码
1处填写你刚刚申请的126邮箱账号
2处填写你刚刚开启的客户端授权密码
3处填写你的126邮箱地址
[root@HE3]# python test_send_mail.py True send_mail_status:success
编译通过
OK,turn on your lepus alert button!~ 适当调低报警阈值,不出10s,你的收件箱应该就收到告警邮件了~
本文出自 “岁伏” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1795014