Closed programmerjake closed 3 months ago
Try setting the log level to trace
and provide the Stalwart logs after a POP3 connection attempt.
Try setting the log level to
trace
and provide the Stalwart logs after a POP3 connection attempt.
ok, done. I added the log.
I would guess you forgot to flush the TlsStream before dropping it, so it doesn't write the final TLS stuff and openssl on the other end complains that the TLS stuff was truncated.
I'm able to reproduce the eof error from python, which likely makes debugging it much easier:
SSLKEYLOGFILE=sslkey.log python3 -c $'import poplib\nc=poplib.POP3_SSL("localhost")\nc.user("forum")\nc.pass_("<password>")\nc.quit()'
Output:
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "/usr/lib/python3.11/poplib.py", line 279, in quit
resp = self._shortcmd('QUIT')
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/poplib.py", line 181, in _shortcmd
return self._getresp()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/poplib.py", line 154, in _getresp
resp, o = self._getline()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/poplib.py", line 138, in _getline
if not line: raise error_proto('-ERR EOF')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
poplib.error_proto: -ERR EOF
Stalwart Logs:
2024-06-28T01:56:53.549554Z DEBUG common::listener::tls: No SNI certificate found by name, using default. context="tls" event="not-found" client_name="localhost"
2024-06-28T01:56:53.550555Z TRACE session{instance="pop3s" protocol=Pop3 remote.ip="172.18.0.1" remote.port=58656}: pop3::session: event="write" data="+OK Stalwart POP3 at your service.\r\n" size=36
2024-06-28T01:56:53.550733Z TRACE session{instance="pop3s" protocol=Pop3 remote.ip="172.18.0.1" remote.port=58656}: pop3::session: event="write" data="+OK forum is a valid mailbox\r\n" size=30
2024-06-28T01:56:53.552998Z TRACE session{instance="pop3s" protocol=Pop3 remote.ip="172.18.0.1" remote.port=58656}: pop3::session: event="write" data="+OK Authentication successful\r\n" size=31
2024-06-28T01:56:53.553087Z DEBUG session{instance="pop3s" protocol=Pop3 remote.ip="172.18.0.1" remote.port=58656}: pop3::session: Disconnecting client. event="disconnect"
looks like you need to call TlsStream::shutdown
(calls poll_shutdown
) which is what sends the TLS close messages. Just dropping the TlsStream
doesn't work since it can't run any async
work in drop
.
also, the QUIT
command is supposed to have a response, but Stalwart doesn't send anything:
https://www.ietf.org/rfc/rfc1939.html#section-6
What happened?
I'm trying to setup a discourse server that uses pop3 polling for a stalwart mail instance on the same host, discourse fails when trying to verify it can connect to the pop3 server. I can connect to the pop3 server and login using the credentials successfully using python.
Apparently someone else also has this problem, but I couldn't find where they reported it to stalwart: https://meta.discourse.org/t/stalwart-mail-discourse-pop3-eof-reached-again/312287
How can we reproduce the problem?
installing discourse and stalwart-mail, try to set up pop3 polling on discourse pointing to an account on the mail server by adding the following code to discourse's app.yml and run
./launcher bootstrap app
:Version
v0.8.x
What database are you using?
SQLite
What blob storage are you using?
RocksDB
Where is your directory located?
None
What operating system are you using?
Docker
Relevant log output
Stalwart's Log:
Discourse Log:
Code of Conduct