Added support for username as notification credentials

pull/463/head
Mike Peters 2020-02-06 09:18:54 +01:00
parent addb885674
commit 7888f54902
2 changed files with 8 additions and 1 deletions

View File

@ -26,6 +26,7 @@ publisher.channel = "Script"
def sendEmailNotification(recipient, alert_name, content): def sendEmailNotification(recipient, alert_name, content):
sender = config_loader.get_config_str("Notifications", "sender") sender = config_loader.get_config_str("Notifications", "sender")
sender_user = config_loader.get_config_str("Notifications", "sender_user")
sender_host = config_loader.get_config_str("Notifications", "sender_host") sender_host = config_loader.get_config_str("Notifications", "sender_host")
sender_port = config_loader.get_config_int("Notifications", "sender_port") sender_port = config_loader.get_config_int("Notifications", "sender_port")
sender_pw = config_loader.get_config_str("Notifications", "sender_pw") sender_pw = config_loader.get_config_str("Notifications", "sender_pw")
@ -49,7 +50,10 @@ def sendEmailNotification(recipient, alert_name, content):
smtp_server = smtplib.SMTP_SSL(sender_host, sender_port) smtp_server = smtplib.SMTP_SSL(sender_host, sender_port)
smtp_server.ehlo() smtp_server.ehlo()
smtp_server.login(sender, sender_pw) if sender_user is not None:
smtp_server.login(sender_user, sender_pw)
else:
smtp_server.login(sender, sender_pw)
else: else:
smtp_server = smtplib.SMTP(sender_host, sender_port) smtp_server = smtplib.SMTP(sender_host, sender_port)

View File

@ -28,6 +28,9 @@ sender = sender@example.com
sender_host = smtp.example.com sender_host = smtp.example.com
sender_port = 1337 sender_port = 1337
sender_pw = None sender_pw = None
# Only needed when the credentials for email server needs a username instead of an email address
#sender_user = sender
sender_user =
# optional for using with authenticated SMTP over SSL # optional for using with authenticated SMTP over SSL
# sender_pw = securepassword # sender_pw = securepassword