summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/notification
diff options
context:
space:
mode:
authorKonstantin Shalygin <k0ste@k0ste.ru>2017-08-19 01:13:24 +0700
committerChris Alfonso <christopher.alfonso@gmail.com>2017-08-18 12:13:24 -0600
commit343da3538137a1192ed7e2e6c01c58c90d663812 (patch)
treea4967457c1ef06349bdccfb7c57c86866fcaa801 /lib/ansible/modules/notification
parent03b888052b43fa777f54936e0086317a5ee97c83 (diff)
downloadansible-343da3538137a1192ed7e2e6c01c58c90d663812.tar.gz
mail: Fix auth over starttls. (#24089)
Diffstat (limited to 'lib/ansible/modules/notification')
-rw-r--r--lib/ansible/modules/notification/mail.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/ansible/modules/notification/mail.py b/lib/ansible/modules/notification/mail.py
index 6560fdf9c9..8856b31819 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: