Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 'user@gmail.com'
SMTP_PASS = 'password'

Expand Down