Skip to content

Commit

Permalink
Allow SMTP configuration without TLS and login
Browse files Browse the repository at this point in the history
  • Loading branch information
ademol committed May 15, 2022
1 parent 9232f31 commit d99f9d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions back/pialert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/pialert.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'
SMTP_PASS = 'password'

Expand Down

0 comments on commit d99f9d5

Please sign in to comment.