mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 09:42:57 -07:00
Catch exception from failed SMTP connection
This commit is contained in:
parent
53aafbd19e
commit
2366a8811b
1 changed files with 5 additions and 3 deletions
|
@ -1318,10 +1318,11 @@ class EMAIL(Notifier):
|
|||
|
||||
recipients = self.config['to'] + self.config['cc'] + self.config['bcc']
|
||||
|
||||
mailserver = None
|
||||
success = False
|
||||
mailserver = smtplib.SMTP(self.config['smtp_server'], self.config['smtp_port'])
|
||||
|
||||
try:
|
||||
mailserver = smtplib.SMTP(self.config['smtp_server'], self.config['smtp_port'])
|
||||
mailserver.ehlo()
|
||||
|
||||
if self.config['tls']:
|
||||
|
@ -1332,14 +1333,15 @@ class EMAIL(Notifier):
|
|||
mailserver.login(str(self.config['smtp_user']), str(self.config['smtp_password']))
|
||||
|
||||
mailserver.sendmail(self.config['from'], recipients, msg.as_string())
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
success = True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
|
||||
finally:
|
||||
if mailserver:
|
||||
mailserver.quit()
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
|
||||
return success
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue