Skip to content

Commit

Permalink
Merge pull request #177 from fazledyn-or/Fix_Weak_Cryptography_SMTP
Browse files Browse the repository at this point in the history
Introduce a safer SMTP alternative: SMTP_SSL (Weak Cryptography Issue)
  • Loading branch information
jtroberts authored Oct 23, 2023
2 parents 216de1c + 1a62a58 commit 529418f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/scripts/oe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, cacheLocation_wmts, cacheLocation_twms, cacheBasename_wmts, c
self.emailRecipient = emailRecipient
self.emailSender = emailSender

def sigevent_email(type, mssg, smtp_server, recipient, sender):
def sigevent_email(type, mssg, smtp_server, recipient, sender, use_ssl=False, mail_user="", mail_pass=""):
"""
Send a sigevent message via email.
Arguments:
Expand Down Expand Up @@ -135,9 +135,18 @@ def sigevent_email(type, mssg, smtp_server, recipient, sender):
msg['From'] = sender
msg['To'] = recipient
try:
s = smtplib.SMTP(smtp_server)
s.sendmail(sender, recipient.replace(",",";").split(";"), msg.as_string())
s.quit()
if use_ssl:
s = smtplib.SMTP_SSL(smtp_server)
if mail_user != "" and mail_pass != "":
s.login(mail_user, mail_pass)
s.sendmail(sender, recipient.replace(",",";").split(";"), msg.as_string())
s.quit()
else:
s = smtplib.SMTP(smtp_server)
if mail_user != "" and mail_pass != "":
s.login(mail_user, mail_pass)
s.sendmail(sender, recipient.replace(",",";").split(";"), msg.as_string())
s.quit()
except Exception as e:
log_info_mssg("ERROR: Cannot send email using SMTP server " + smtp_server + ", " + str(e))

Expand Down

0 comments on commit 529418f

Please sign in to comment.