From 96cd0a8a10309d89f9d8b2e02d49276144366d95 Mon Sep 17 00:00:00 2001 From: Volker Gropp Date: Fri, 29 May 2020 12:24:43 +0200 Subject: [PATCH] fix: error server_hostname cannot be an empty string https://github.com/ansible/ansible/pull/44552 --- mailproxy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mailproxy.py b/mailproxy.py index 7dbed8d..d9c55b7 100644 --- a/mailproxy.py +++ b/mailproxy.py @@ -39,9 +39,9 @@ def _deliver(self, envelope): refused = {} try: if self._use_ssl: - s = smtplib.SMTP_SSL() + s = smtplib.SMTP_SSL(self._host) else: - s = smtplib.SMTP() + s = smtplib.SMTP(self._host) s.connect(self._host, self._port) if self._starttls: s.starttls() @@ -59,7 +59,7 @@ def _deliver(self, envelope): except (OSError, smtplib.SMTPException) as e: logging.exception('got %s', e.__class__) # All recipients were refused. If the exception had an associated - # error code, use it. Otherwise, fake it with a SMTP 554 status code. + # error code, use it. Otherwise, fake it with a SMTP 554 status code. errcode = getattr(e, 'smtp_code', 554) errmsg = getattr(e, 'smtp_error', e.__class__) raise smtplib.SMTPResponseException(errcode, errmsg.decode()) @@ -78,7 +78,7 @@ def _deliver(self, envelope): config = configparser.ConfigParser() config.read(config_path) - + use_auth = config.getboolean('remote', 'smtp_auth', fallback=False) if use_auth: auth = { @@ -87,7 +87,7 @@ def _deliver(self, envelope): } else: auth = None - + controller = Controller( MailProxyHandler( host=config.get('remote', 'host'),