mail: Fix regression when sending mail without SSL (v2.7) (#47019)

* mail: Fix regression when sending mail without SSL (v2.7)

When this module was refactored in #37098 the non-SSL use-case was broken.

The main cause is that we have no way to do integration tests for testing SMTP.

This is a back-port to v2.7 of #46403

* Add changelog fragment
This commit is contained in:
Dag Wieers 2018-10-23 01:45:21 +02:00 committed by Toshio Kuratomi
parent 0e933f76ba
commit 44ae37d78b
2 changed files with 4 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- mail - Fix regression when sending mail without TLS/SSL

View file

@ -255,6 +255,8 @@ def main():
if secure == 'always':
module.fail_json(rc=1, msg='Unable to start an encrypted session to %s:%s: %s' %
(host, port, to_native(e)), exception=traceback.format_exc())
except:
pass
if not secure_state:
smtp = smtplib.SMTP(timeout=timeout)