Merge pull request #463 from petmi627/master

Added support for username as notification credentials
pull/486/head
Thirion Aurélien 2020-02-06 09:49:43 +01:00 committed by GitHub
commit c7979d81e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -26,6 +26,7 @@ publisher.channel = "Script"
def sendEmailNotification(recipient, alert_name, content):
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_port = config_loader.get_config_int("Notifications", "sender_port")
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.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:
smtp_server = smtplib.SMTP(sender_host, sender_port)

View File

@ -28,6 +28,9 @@ sender = sender@example.com
sender_host = smtp.example.com
sender_port = 1337
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
# sender_pw = securepassword