我只是在 ubuntu 22.04(全新安装)vps 上安装了一个 mailcow 邮件服务器,我可以很好地连接我的邮件客户端(Evolution),但是在尝试使用 imaplib 从 python 脚本连接时遇到问题:
我的客户端是 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')
出现此错误:
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)
我已经尝试在两个选项中使用 ssl 上下文:
# PROTOCOL_SSLv23
# PROTOCOL_TLS
# PROTOCOL_TLS_CLIENT
# PROTOCOL_TLSv1
# PROTOCOL_TLSv1_1
# PROTOCOL_TLSv1_2
我猜是关于一些服务器端配置,但我是 mailcow 和 dovecot 的新手