catch connection refused error on smtp check

This commit is contained in:
Yannik Schmidt
2020-09-06 03:03:55 +02:00
parent bcdfbe9391
commit 772a127547

View File

@@ -11,7 +11,7 @@ def checkSMTPConnection(app):
if app.config["TARGET_SMTP_USER"] and app.config["TARGET_SMTP_PASSWORD"]: if app.config["TARGET_SMTP_USER"] and app.config["TARGET_SMTP_PASSWORD"]:
smtp.login(app.config["TARGET_SMTP_USER"], app.config["TARGET_SMTP_PASSWORD"]) smtp.login(app.config["TARGET_SMTP_USER"], app.config["TARGET_SMTP_PASSWORD"])
smtpTarget.quit() smtpTarget.quit()
except smtplib.SMTPException as e: except (smtplib.SMTPException, ConnectionRefusedError) as e:
if app.config["SMTP_MUST_BE_CONNECTED"]: if app.config["SMTP_MUST_BE_CONNECTED"]:
print(e, file=sys.stderr) print(e, file=sys.stderr)
sys.exit(1) sys.exit(1)