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.smtp_password = config['smtp_password']
|
||||||
self.to_email = config['to_email']
|
self.to_email = config['to_email']
|
||||||
self.use_tls = config.get('use_tls', True)
|
self.use_tls = config.get('use_tls', True)
|
||||||
|
self.use_ssl = config.get('use_ssl', False)
|
||||||
|
|
||||||
def send(self, notifications):
|
def send(self, notifications):
|
||||||
"""发送邮件通知"""
|
"""发送邮件通知"""
|
||||||
@@ -39,9 +40,12 @@ class EmailNotifier:
|
|||||||
msg.attach(MIMEText(html_body, 'html', 'utf-8'))
|
msg.attach(MIMEText(html_body, 'html', 'utf-8'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server = smtplib.SMTP(self.smtp_host, self.smtp_port)
|
if self.use_ssl:
|
||||||
if self.use_tls:
|
server = smtplib.SMTP_SSL(self.smtp_host, self.smtp_port)
|
||||||
server.starttls()
|
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.login(self.smtp_user, self.smtp_password)
|
||||||
server.send_message(msg)
|
server.send_message(msg)
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|||||||
Reference in New Issue
Block a user