diff --git a/README.MD b/README.MD index c3810e7..41386ab 100644 --- a/README.MD +++ b/README.MD @@ -13,7 +13,20 @@ ## 截图 ![Hawkeye](https://user-images.githubusercontent.com/12611275/46849889-0d2d0980-ce24-11e8-832e-35f6f935bf3b.png) + + + +## dbg 更新 + +- 2019/11/14 + - 更新邮件发送title + + + + + ## **最近更新** + - 2019-07-02 v3.0.1 - 添加健康检查接口 /api/health - 添加企业微信告警 diff --git a/server/utils/notice.py b/server/utils/notice.py index 3101f5c..cf12cf2 100644 --- a/server/utils/notice.py +++ b/server/utils/notice.py @@ -1,6 +1,7 @@ import smtplib from email.header import Header from email.mime.text import MIMEText +import time class SMTPServer(object): @@ -11,10 +12,10 @@ def __init__(self, smtp_config): self.username = smtp_config.get('username') self.password = smtp_config.get('password') try: - if self.tls: - self.smtp = smtplib.SMTP(self.host, self.port, timeout=300) - else: + if self.tls: self.smtp = smtplib.SMTP_SSL(self.host, self.port, timeout=300) + else: + self.smtp = smtplib.SMTP(self.host, self.port, timeout=300) except Exception as error: print(error) @@ -48,7 +49,7 @@ def mail_notice(smtp_config, receivers, content): message = MIMEText(content, _subtype='html', _charset='utf-8') message['From'] = Header('{}<{}>'.format(smtp_config.get('from'), smtp_config.get('username')), 'utf-8') message['To'] = Header(';'.join(receivers), 'utf-8') - message['Subject'] = Header('[GitHub] 监控告警', 'utf-8') + message['Subject'] = Header('[GitHub] 监控告警--'+time.asctime(), 'utf-8') try: smtp = SMTPServer(smtp_config) print('login')