Can't configure plone to send email

I still can't get Plone setup to send emails. I have done this before with previous setups using local host.
Is anyone else facing this challenge setting up smtp?

I learned from @davisagli that plone6 installed via docker does not have smtp code included. Might that be the issue and would installing smtp solve my issues? (see below for details). I realize the localhost is different from external smtp server; however, the error below doesn't seem to differentiate from localhost or external host

if installing would solve, how would i do that?

any help would be appreciated. I'm dead in the water with my site until I get this fixed.


I've tied:

  • Local Host
  • Google smtp
  • two emails servers setup on different accounts and different domains.

error messages i've gotten:

  • Error: Unable to send test e-mail [Errno 101] Network is unreachable. (when 'localhost' is used)
  • Error: Unable to send test e-mail Connection unexpectedly closed: timed out. (Note: this is the error in
    the log below

I have tried many setups - Configuring Plone email SMTP when ssl is required - #4 by davisagli


More Details

Error from log

2023-04-14 00:00:29 ERROR [Plone:89][waitress-0] Unable to send test e-mail.
Traceback (most recent call last):
File "/usr/local/lib/python3.11/smtplib.py", line 398, in getreply
line = self.file.readline(_MAXLINE + 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/socket.py", line 706, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/lib/python3.11/site-packages/Products/CMFPlone/controlpanel/browser/mail.py", line 80, in handle_test_action
mailhost.send(message,
File "/app/lib/python3.11/site-packages/Products/MailHost/MailHost.py", line 215, in send
self._send(mfrom, mto, msg, immediate)
File "/app/lib/python3.11/site-packages/Products/MailHost/MailHost.py", line 322, in _send
self._makeMailer().send(mfrom, mto, messageText)
File "/app/lib/python3.11/site-packages/zope/sendmail/mailer.py", line 89, in send
self.vote(fromaddr, toaddrs, message)
File "/app/lib/python3.11/site-packages/zope/sendmail/mailer.py", line 62, in vote
self.connection = self.smtp(self.hostname, str(self.port))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 255, in init
(code, msg) = self.connect(host, port)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 343, in connect
(code, msg) = self.getreply()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 401, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed: "
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

Wayne Glover via Plone Community wrote at 2023-4-14 00:36 +0000:

...
I've tied:

  • Local Host
  • Google smtp
  • two emails servers setup on different accounts and different domains.

error messages i've gotten:

  • Error: Unable to send test e-mail [Errno 101] Network is unreachable. (when 'localhost' is used)

This does not look like a Plone problem:
The error message shows that low level network code has been reached.
Thus, your message went most of its way to the SMTP server
and failed near the end.

I am a bit surprised that the localhost network should
be unreachable. Are you sure that localhost is working
properly on the host?

If you are on a nix system, you could try the following commands:

  • host localhost
    You should see something like:
    localhost has address 127.0.0.1
    localhost has IPv6 address ::1
  • ifconfig
    Look for inet 127.0.0.1

...
Error from log

2023-04-14 00:00:29 ERROR [Plone:89][waitress-0] Unable to send test e-mail.
Traceback (most recent call last):
File "/usr/local/lib/python3.11/smtplib.py", line 398, in getreply
line = self.file.readline(_MAXLINE + 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/socket.py", line 706, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out

Looks like some malfunction of or incompatibility with the SMTP
server.

The error information shows you:

  • the connection with the SMTP server has already been established
  • a command has been sent
  • waiting for the reply was aborted by a timeout

For some reason, the contacted SMTP server did not send
the reply sufficiently fast -- maybe, because it still
waits for more data.

Recently, I have seen problem reports regarding Plone's
email sending with some (primarily Windows) SMTP servers.
The problem: Plone does not guaranteed that emails
use \r\n line separators -- as required by the SMTP protocol.
Most SMTP servers also work properly with \n line separators
(used by Plone), but some insist on SMTP compliance and
fail otherwise.
See
"quoted-printable soft line breaks not always correctly recognized · Issue #35 · zopefoundation/Products.MailHost · GitHub"
or
"Use patched message_from_string · Issue #3754 · plone/Products.CMFPlone · GitHub".

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
self.connection = self.smtp(self.hostname, str(self.port))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 255, in init
(code, msg) = self.connect(host, port)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 343, in connect
(code, msg) = self.getreply()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 401, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed: "
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

This traceback shows you that the timeout occured as part of the
connect -- i.e. before any email data has been sent.
Thus, you are not facing the problem mentioned above.

Looking at the smtplib code, I can see that the SMTP server
did not send the initial message.
A potential cause could be that the contacted server is
not an SMTP server.
Potentially, it is an SMTPS server.

@rileydog
Depending on who you host with, they may be blocking the smtp sending port. Not sure if that is still a thing.

@dieter thanks so much for the analysis of the log.

To make sure i have it right:
1. the issue of this version of Plone not having localhost is a non-issue because I am not using a localhost i am connecting to an "external" smtp server (I know this is probably obvious to you, but I wanted to ask the question)

  1. plone tries to connect to the specified external smtp; however, as you said:

so, going into my way back machine - this is like dial up internet when the modems would exchange handshakes. In this case the smtp on my external smtp server does not acknowledge the "handshake" from Plone. you are speculating it might be the smtp on my external server is a smtps server and thus ignores the insecure contact from Plone.

Do i have this correct?
I will look into the smtps server question.

Thanks again.

Wayne Glover via Plone Community wrote at 2023-4-15 02:44 +0000:

...
To make sure i have it right:

  1. the issue of this version of Plone not having localhost is a non-issue because I am not using a localhost i am connecting to an "external" smtp server

I do not think you got this right:
You have reported that your trial to use localhost resulted
in a "network is unreachable" error message.
This is not a non-issue -- but the problem is not caused by Plone.
Plone was able to transfer the email message down to low level
network code (i.e. Plone did its job) but the network layer
detected that the targeted network is unreachabe (very
surprising for the network localhost belongs to).

  1. plone tries to connect to the specified external smtp; however, as you said:

so, going into my way back machine - this is like dial up internet when the modems would exchange handshakes. In this case the smtp on my external smtp server does not acknowledge the "handshake" from Plone. you are speculating it might be the smtp on my external server is a smtps server and thus ignores the insecure contact from Plone.

The traceback shows that Plone has successfully opened a
connection to the specified server port and is now waiting
for the initial response. This waiting is aborted due to a timeout.

The most natural hypothesis is that the targeted server
is not an SMTP server (which would send a response).
It might be an SMTPS server (which expects an encryption
negotiation before it replies on the SMTP level),
it might be some other server (e.g. a telnet server).

Alternatively, it could be a firewall between
your and the server host which discards data packets
(however I would expect that in this case, the connection
establishment rather than the waiting for the first response
would time out).

Do i have this correct?

At least not completely.

Anyway: the problem you observe is almost surely not caused by
Plone.

Note that Plone (more precisely Products.MailHost)
does not support SMTPS servers:
there are 2 types to communicate over an encrypted communication
channel with a mail server:

  1. SMTP + starttls
  2. SMTPS (which is SMTP over a TLS communication channel)
    Plone supports only the first type.

First, thanks for the detailed help you have given me. I’ve dug in and learned a lot about email servers, security and studied differences between ssl/tls and starttls to understand how this would affect what I’m trying to do.

three key points to ensure we agree:

  1. SSL vs. TLS: SSL and its successor, TLS, are protocols that encrypt internet traffic to make it secure for communication.

  2. Starttls is the command to force an ssl connection

  3. You stated Plone only supports SMTP and starttls. This means we should see Plone talk to the smtp server – give the command ‘starttls” which forces an ssl connection and then goes from there
    Second, I’d like to ask a basic question (I’m going to post this as a new question to the entire community): what commercial email service do you use that works with Plone? I can move my email server (or entire site) as required to fix this issue. I don’t want to keep imposing on you if I can make a change that fixes the issue.


Steps I’ve Taken

  1. Created two new emails with different domains on different servers.

  2. Went to //email/testTo: to test for STARTTLS connection (I noted you stated Plone only supports SMTP and starttls so I figured this was a key issue to check). (Note: in this test I did not compel or direct TLS (two of the settings available)

  3. Below is a portion of the readout when checking wayne@rileydog.info. The key parts of the readout were the same for both emails.

  4. Key point is both smtp servers replied: “starttls command works on this server” then “connection converted to ssl”. This shows the starttls has successfully forced an ssl connection. (my new understanding of what “starttls command” does.

  5. as best I can tell this means Plone should be able to connect

Thoughts? Is no one else having this issue??

below is the relevant portion of the log file


Trying TLS on in1-smtp.messagingengine.com[66.111.4.73:25] (10)
[000.009] Server answered
[001.078] < 220 mx4.messagingengine.com ESMTP mx. No UCE permitted.
[001.078] We are allowed to connect
[001.078] > EHLO www12-azure.checktls.com
[001.090] < 250-mx4.messagingengine.com
250-PIPELINING
250-SIZE 73000000
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 CHUNKING
[001.090] We can use this server
[001.090] TLS is an option on this server
[001.090] > STARTTLS
[001.099] < 220 2.0.0 Ready to start TLS
[001.100] STARTTLS command works on this server
[001.120] Connection converted to SSL

Wayne Glover via Plone Community wrote at 2023-4-15 22:52 +0000:

...
5) as best I can tell this means Plone should be able to connect

The traceback you provided previously showed that
the timeout error occurred before any starttls could be issued.
My hypothesis was that the contacted server did not expect SMTP.
But a firewall (dropping packets) could also be a reason (mentioned as
well).

Your description here seems to indicate that you have tried
to directly send the email to the final mail servers.
Some mail servers use techniques to prevent this in order
to avoid abuse. For example, they may insist
that the incoming connection comes from a DNS (= "Domain Name Service")
registered mail host.
Check with an email client (e.g. outlook or thunderbird)
(from the host you run Plone on)
that the email servers you try to contact allow direct
SMTP access.

@dieter thanks for that final tip (trying to send directly to final email server)

I've contacted my host tech support and am trying to properly configure email without going directly

thanks - I'll update after new email server settings have time to propagate

fixed!

@dieter @pigeonflight

Thanks for all your help. Sadly i must admit I got sucked down the rabbit hole (interesting, but time consuming) and none of the deep technical issues were the problem (as I'm sure you both knew from the beginning :slight_smile:
as both have mentioned, the issue was trying to directly connect to the mail smtp.
the directions from my host works from outlook etc. ; however, i needed a different server address for Plone (not sure why).
I use cpanel for my sever and the magic server address turned out to be: 125.50.167.72.host.secureserver.net the IP goes to my cpanel account.

Thanks so much I apologize if you didn't find the ride as interesting as I did, but I wouldn't have thought to look for the "indirect" smtp server address without your help.

1 Like