我遇到问题的环境:Windows10 上的 Python 2.7.11(已更新)。通过 msi 安装的 Python。我检查了设置中的 PATH 设置,它设置为 c:\Python27。
这适用于 Mac:
from imapclient import IMAPClient
IMAPClient("imap-mail.outlook.com", use_uid=True, ssl=(True))
但在 Windows 上,如果 barfs 像这样:
Traceback (most recent call last):
File "test_outlook_imap.py", line 3, in <module>
IMAPClient("imap-mail.outlook.com", use_uid=True, ssl=(True))
File "C:\Python27\lib\site-packages\imapclient\imapclient.py", line 152, in __init__
self._imap = self._create_IMAP4()
File "C:\Python27\lib\site-packages\imapclient\imapclient.py", line 164, in _create_IMAP4
self._timeout)
File "C:\Python27\lib\site-packages\imapclient\tls.py", line 153, in __init__
imaplib.IMAP4.__init__(self, host, port)
File "C:\Python27\lib\imaplib.py", line 173, in __init__
self.open(host, port)
File "C:\Python27\lib\site-packages\imapclient\tls.py", line 159, in open
self.sock = wrap_socket(sock, self.ssl_context, host)
File "C:\Python27\lib\site-packages\imapclient\tls.py", line 126, in wrap_socket
ssl_context = create_default_context()
File "C:\Python27\lib\site-packages\imapclient\tls.py", line 109, in create_default_context
context.load_verify_locations(cadata=certs)
File "C:\Python27\lib\site-packages\backports\ssl\core.py", line 654, in load_verify_locations
self._ctx.load_verify_locations(cafile, capath)
File "C:\Python27\lib\site-packages\OpenSSL\SSL.py", line 528, in load_verify_locations
_raise_current_error()
File "C:\Python27\lib\site-packages\OpenSSL\_util.py", line 48, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: []
这与 Window 对证书链的处理有关吗?
顺便说一句,它对 imap.gmail.com 代替 Outlook 域的作用相同。