Exim MTA Relay: Plone OSError: [Errno 99] Cannot assign requested address

I have exim relay running on localhost but plone is unable to send a test email. I have tested using python3 smtplib and able to send email properly.

backend_1     | 2022-06-20 15:47:43 ERROR [Plone:88][waitress-0] Unable to send test e-mail.
backend_1     | Traceback (most recent call last):
backend_1     |   File "/app/lib/python3.9/site-packages/Products/CMFPlone/controlpanel/browser/mail.py", line 79, in handle_test_action
backend_1     |     mailhost.send(message,
backend_1     |   File "/app/lib/python3.9/site-packages/Products/MailHost/MailHost.py", line 214, in send
backend_1     |     self._send(mfrom, mto, msg, immediate)
backend_1     |   File "/app/lib/python3.9/site-packages/Products/MailHost/MailHost.py", line 321, in _send
backend_1     |     self._makeMailer().send(mfrom, mto, messageText)
backend_1     |   File "/app/lib/python3.9/site-packages/zope/sendmail/mailer.py", line 89, in send
backend_1     |     self.vote(fromaddr, toaddrs, message)
backend_1     |   File "/app/lib/python3.9/site-packages/zope/sendmail/mailer.py", line 62, in vote
backend_1     |     self.connection = self.smtp(self.hostname, str(self.port))
backend_1     |   File "/usr/local/lib/python3.9/smtplib.py", line 255, in __init__
backend_1     |     (code, msg) = self.connect(host, port)
backend_1     |   File "/usr/local/lib/python3.9/smtplib.py", line 341, in connect
backend_1     |     self.sock = self._get_socket(host, port, self.timeout)
backend_1     |   File "/usr/local/lib/python3.9/smtplib.py", line 312, in _get_socket
backend_1     |     return socket.create_connection((host, port), timeout,
backend_1     |   File "/usr/local/lib/python3.9/socket.py", line 844, in create_connection
backend_1     |     raise err
backend_1     |   File "/usr/local/lib/python3.9/socket.py", line 832, in create_connection
backend_1     |     sock.connect(sa)
backend_1     | OSError: [Errno 99] Cannot assign requested address
backend_1     | 2022-06-20 15:47:43 ERROR [Plone:88][waitress-0] Unable to send test e-mail.
backend_1     | Traceback (most recent call last):
backend_1     |   File "/app/lib/python3.9/site-packages/Products/CMFPlone/controlpanel/browser/mail.py", line 79, in handle_test_action
backend_1     |     mailhost.send(message,
backend_1     |   File "/app/lib/python3.9/site-packages/Products/MailHost/MailHost.py", line 214, in send
backend_1     |     self._send(mfrom, mto, msg, immediate)
backend_1     |   File "/app/lib/python3.9/site-packages/Products/MailHost/MailHost.py", line 321, in _send
backend_1     |     self._makeMailer().send(mfrom, mto, messageText)
backend_1     |   File "/app/lib/python3.9/site-packages/zope/sendmail/mailer.py", line 89, in send
backend_1     |     self.vote(fromaddr, toaddrs, message)
backend_1     |   File "/app/lib/python3.9/site-packages/zope/sendmail/mailer.py", line 62, in vote
backend_1     |     self.connection = self.smtp(self.hostname, str(self.port))
backend_1     |   File "/usr/local/lib/python3.9/smtplib.py", line 255, in __init__
backend_1     |     (code, msg) = self.connect(host, port)
backend_1     |   File "/usr/local/lib/python3.9/smtplib.py", line 341, in connect
backend_1     |     self.sock = self._get_socket(host, port, self.timeout)
backend_1     |   File "/usr/local/lib/python3.9/smtplib.py", line 312, in _get_socket
backend_1     |     return socket.create_connection((host, port), timeout,
backend_1     |   File "/usr/local/lib/python3.9/socket.py", line 844, in create_connection
backend_1     |     raise err
backend_1     |   File "/usr/local/lib/python3.9/socket.py", line 832, in create_connection
backend_1     |     sock.connect(sa)
backend_1     | OSError: [Errno 99] Cannot assign requested address
mail:
    image: docker.io/devture/exim-relay:latest
    user: 100:101
    restart: always
    ports:
      - "127.0.0.1:25:8025"
    environment:
      HOSTNAME: "example.com"
      DISABLE_SENDER_VERIFICATION: "True"
      RELAY_FROM_HOSTS: "10.0.0.0/8:172.16.0.0/12:192.168.0.0/16"

Arky via Plone Community wrote at 2022-6-20 16:39 +0000:

I have exim relay running on localhost but plone is unable to send a test email. I have tested using python3 smtplib and able to send email properly.
...
backend_1 | return socket.create_connection((host, port), timeout,
backend_1 | File "/usr/local/lib/python3.9/socket.py", line 844, in create_connection
backend_1 | raise err
backend_1 | File "/usr/local/lib/python3.9/socket.py", line 832, in create_connection
backend_1 | sock.connect(sa)
backend_1 | OSError: [Errno 99] Cannot assign requested address

Error 99 is EADDRNOTAVAIL documented by:

     The socket referred to by  sockfd  had
     not  previously been bound to an address and, upon attempting to
     bind it to an ephemeral port, it was determined  that  all  port
     numbers  in  the ephemeral port range are currently in use.  See
     the  discussion  of  /proc/sys/net/ipv4/ip_local_port_range   in
     ip(7).

This suggests that you do not see a Plone problem:
the low level connect was unable to obtain a local port
to represent the local communication point for the connection
to be created.
Check the port usage in your system (maybe via lsof -i)
and your port related system configuration.

1 Like

Also, if the ephemeral ports are available, check if your zeoclient process is running out of file descriptors.

On some systems the max open fd’s can be a very low default. Also depending on OS. Subprocesses add to the max fd limit of the parent process.

1 Like

Something strange was happening in the docker default network. Now the default network containers backend <-> mail correctly linked in the default network.

Resolve the issue by using alternative postfix container (config below). And in the Plone Mail Settings set 'SMTP Server: mail' and 'SMTP port: 25'.

 mail:
    image: eeacms/postfix
    restart: always
    ports:
      - "127.0.0.1:25:25"
    environment:
      - MTP_HOST=foo.com