From 343da3538137a1192ed7e2e6c01c58c90d663812 Mon Sep 17 00:00:00 2001 From: Konstantin Shalygin Date: Sat, 19 Aug 2017 01:13:24 +0700 Subject: [PATCH] mail: Fix auth over starttls. (#24089) --- lib/ansible/modules/notification/mail.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/ansible/modules/notification/mail.py b/lib/ansible/modules/notification/mail.py index 6560fdf9c9f..8856b318198 100644 --- a/lib/ansible/modules/notification/mail.py +++ b/lib/ansible/modules/notification/mail.py @@ -246,7 +246,6 @@ def main(): sender_phrase, sender_addr = parseaddr(sender) secure_state = False code = 0 - auth_flag = "" if not body: body = subject @@ -269,7 +268,6 @@ def main(): module.fail_json(rc=1, msg='Unable to Connect to %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc()) - if (secure == 'always'): try: smtp = smtplib.SMTP_SSL(timeout=timeout) @@ -286,8 +284,6 @@ def main(): module.fail_json(rc=1, msg='Helo failed for host %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc()) - auth_flag = smtp.has_extn('AUTH') - if secure in ('try', 'starttls'): if smtp.has_extn('STARTTLS'): try: @@ -303,7 +299,7 @@ def main(): module.fail_json(rc=1, msg='StartTLS is not offered on server %s:%s' % (host, port)) if username and password: - if auth_flag: + if smtp.has_extn('AUTH'): try: smtp.login(username, password) except smtplib.SMTPAuthenticationError: