SMTP Connection Error Hides Unrelated Error
I have been trying to debug an issue where mailman reports that it cannot connect to my mail server. The log always contained this error message, no matter what I did:
Cannot connect to SMTP server mailserver on port 25
After checking the network setup for ages, I modified runners/outgoing.py#95 ff like this to debug the error:
except socket.error as socket_error:
# There was a problem connecting to the SMTP server. Log this
# once, but crank up our sleep time so we don't fill the error
# log.
port = int(config.mta.smtp_port)
if port == 0:
port = 'smtp' # Log this just once.
if not self._logged:
log.error('Cannot connect to SMTP server %s on port %s: %s',
config.mta.smtp_host, port, socket_error)
self._logged = True
return True
To my surprise, socket.error
was not related to SMTP in any way. The new error message was:
Cannot connect to SMTP server mailserver on port 25: HTTPConnectionPool(host='mailman-web', port=80): Max retries exceeded with url: /postorius/api/templates/domain/studierlangsam.de/list:member:regular:footer (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f55089e2a90>: Failed to establish a new connection: [Errno 111] Connection refused',))
I have not debugged this nested error yet, but I think that it’s quite clear that an exception is coming from trying to connect to postorius.
The issue seems to be that the exception thrown while connecting postorius is not handled and thus obscured when being handled by outgoing.py
.