Reputation: 21
I just install a mailcow mail server on a ubuntu 22.04(fresh install) vps, i can connect well with my mail client (Evolution), but have issue when trying to connect from a python script using imaplib:
my client side is Ubuntu 22.10 Mate with Python 3.10
import imaplib
imap = imaplib.IMAP4_SSL("mail.mysite.com", 143)
imap.login('[email protected]','a_strong_password')
getting this error:
Traceback (most recent call last):
File "/home/cc1/python/mail/imap_test.py", line 12, in <module>
imap = imaplib.IMAP4_SSL("mail.mysite.com", 143)
File "/usr/lib/python3.10/imaplib.py", line 1323, in __init__
IMAP4.__init__(self, host, port, timeout)
File "/usr/lib/python3.10/imaplib.py", line 202, in __init__
self.open(host, port, timeout)
File "/usr/lib/python3.10/imaplib.py", line 1336, in open
IMAP4.open(self, host, port, timeout)
File "/usr/lib/python3.10/imaplib.py", line 312, in open
self.sock = self._create_socket(timeout)
File "/usr/lib/python3.10/imaplib.py", line 1327, in _create_socket
return self.ssl_context.wrap_socket(sock,
File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.10/ssl.py", line 1071, in _create
self.do_handshake()
File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)
I already try using ssl context with both options:
# PROTOCOL_SSLv23
# PROTOCOL_TLS
# PROTOCOL_TLS_CLIENT
# PROTOCOL_TLSv1
# PROTOCOL_TLSv1_1
# PROTOCOL_TLSv1_2
here the config of my mail client working well: mail client
i guess its about some server side config, but i'm new to mailcow and dovecot
Upvotes: 1
Views: 814
Reputation: 21
Just find out my problem:
replacing
imap = imaplib.IMAP4_SSL("mail.mysite.com", 143)
by
imap = imaplib.IMAP4_SSL("mail.mysite.com")
and then it works well
Upvotes: 1