From 44ae37d78b5256b704a0edbc682e74a4c403822c Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 23 Oct 2018 01:45:21 +0200 Subject: [PATCH] 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 --- changelogs/fragments/mail-fix-regression.yaml | 2 ++ lib/ansible/modules/notification/mail.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/mail-fix-regression.yaml diff --git a/changelogs/fragments/mail-fix-regression.yaml b/changelogs/fragments/mail-fix-regression.yaml new file mode 100644 index 00000000000..e5a6ed7bb76 --- /dev/null +++ b/changelogs/fragments/mail-fix-regression.yaml @@ -0,0 +1,2 @@ +bugfixes: +- mail - Fix regression when sending mail without TLS/SSL diff --git a/lib/ansible/modules/notification/mail.py b/lib/ansible/modules/notification/mail.py index e1713e90d9e..c5fe5867275 100644 --- a/lib/ansible/modules/notification/mail.py +++ b/lib/ansible/modules/notification/mail.py @@ -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)