fix 25 port no reach /. problem
This commit is contained in:
10
notifier.py
10
notifier.py
@@ -19,6 +19,7 @@ class EmailNotifier:
|
||||
self.smtp_password = config['smtp_password']
|
||||
self.to_email = config['to_email']
|
||||
self.use_tls = config.get('use_tls', True)
|
||||
self.use_ssl = config.get('use_ssl', False)
|
||||
|
||||
def send(self, notifications):
|
||||
"""发送邮件通知"""
|
||||
@@ -39,9 +40,12 @@ class EmailNotifier:
|
||||
msg.attach(MIMEText(html_body, 'html', 'utf-8'))
|
||||
|
||||
try:
|
||||
server = smtplib.SMTP(self.smtp_host, self.smtp_port)
|
||||
if self.use_tls:
|
||||
server.starttls()
|
||||
if self.use_ssl:
|
||||
server = smtplib.SMTP_SSL(self.smtp_host, self.smtp_port)
|
||||
else:
|
||||
server = smtplib.SMTP(self.smtp_host, self.smtp_port)
|
||||
if self.use_tls:
|
||||
server.starttls()
|
||||
server.login(self.smtp_user, self.smtp_password)
|
||||
server.send_message(msg)
|
||||
server.quit()
|
||||
|
||||
Reference in New Issue
Block a user