autobuild: attempt authenticated email if environment suggests it
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 3 Apr 2019 00:17:17 +0000 (13:17 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 5 Apr 2019 04:41:25 +0000 (04:41 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
script/autobuild.py

index d62e721a3cd13488b9d1c6b4ba679639ffe1acb0..0f95cc50bc88eaaf31adfc1b79e28570be8f62dd 100755 (executable)
@@ -910,6 +910,12 @@ def send_email(subject, text, log_tar):
         outer.attach(msg)
     content = outer.as_string()
     s = smtplib.SMTP(options.email_server)
+    email_user = os.getenv('SMTP_USERNAME')
+    email_password = os.getenv('SMTP_PASSWORD')
+    if email_user is not None:
+        s.starttls()
+        s.login(email_user, email_password)
+
     s.sendmail(options.email_from, [options.email], content)
     s.set_debuglevel(1)
     s.quit()