mail: fixed STARTTLS module working with python 3.7.0 (#47412)

(cherry picked from commit 8c9070ec05)
pull/48392/head
Konstantin Shalygin 6 years ago committed by Toshio Kuratomi
parent 71ee1adf0b
commit 0ee072fffc

@ -0,0 +1,2 @@
bugfixes:
- fix mail notification module when using starttls and py3.7

@ -248,8 +248,8 @@ def main():
try: try:
if secure != 'never': if secure != 'never':
try: try:
smtp = smtplib.SMTP_SSL(host=host, timeout=timeout) smtp = smtplib.SMTP_SSL(host=host, port=port, timeout=timeout)
code, smtpmessage = smtp.connect(host, port=port) code, smtpmessage = smtp.connect(host, port)
secure_state = True secure_state = True
except ssl.SSLError as e: except ssl.SSLError as e:
if secure == 'always': if secure == 'always':
@ -259,8 +259,8 @@ def main():
pass pass
if not secure_state: if not secure_state:
smtp = smtplib.SMTP(timeout=timeout) smtp = smtplib.SMTP(host=host, port=port, timeout=timeout)
code, smtpmessage = smtp.connect(host, port=port) code, smtpmessage = smtp.connect(host, port)
except smtplib.SMTPException as e: except smtplib.SMTPException as e:
module.fail_json(rc=1, msg='Unable to Connect %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc()) module.fail_json(rc=1, msg='Unable to Connect %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc())

Loading…
Cancel
Save