From d99f9d5dcab28e4eae5f74d1dc3d953b3cdda7a9 Mon Sep 17 00:00:00 2001 From: Arjan de Mol <9993695+ademol@users.noreply.github.com> Date: Sun, 15 May 2022 14:54:15 +0200 Subject: [PATCH] Allow SMTP configuration without TLS and login --- back/pialert.py | 13 ++++++++++--- config/pialert.conf | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/back/pialert.py b/back/pialert.py index 1a1e5da70..054fcbf55 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1413,12 +1413,19 @@ def send_email (pText, pHTML): # Send mail smtp_connection = smtplib.SMTP (SMTP_SERVER, SMTP_PORT) smtp_connection.ehlo() - smtp_connection.starttls() - smtp_connection.ehlo() - smtp_connection.login (SMTP_USER, SMTP_PASS) + if not SafeParseGlobalBool("SMTP_SKIP_TLS"): + smtp_connection.starttls() + smtp_connection.ehlo() + if not SafeParseGlobalBool("SMTP_SKIP_LOGIN"): + smtp_connection.login (SMTP_USER, SMTP_PASS) smtp_connection.sendmail (REPORT_FROM, REPORT_TO, msg.as_string()) smtp_connection.quit() +#------------------------------------------------------------------------------- +def SafeParseGlobalBool(boolVariable): + if boolVariable in globals(): + return eval(boolVariable) + return False #=============================================================================== # DB diff --git a/config/pialert.conf b/config/pialert.conf index 65c0bf03a..d4b1ff3c3 100644 --- a/config/pialert.conf +++ b/config/pialert.conf @@ -15,6 +15,8 @@ PRINT_LOG = False SMTP_SERVER = 'smtp.gmail.com' SMTP_PORT = 587 +SMTP_SKIP_TLS = False +SMTP_SKIP_LOGIN = False SMTP_USER = 'user@gmail.com' SMTP_PASS = 'password'