python 3中的以下代码在我的计算机上引发错误,我不知道如何正确登录:
import smtplib
connection = smtplib.SMTP('smtp-mail.outlook.com', 587)
connection.ehlo()
connection.starttls()
connection.ehlo()
connection.login('_these_dont_matter@outlook.com', '_the_error_persists_')
最后一行产生以下输出:
Traceback (most recent call last):
File "/usr/lib/python3.3/smtplib.py", line 366, in getreply
line = self.file.readline()
File "/usr/lib/python3.3/socket.py", line 297, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.3/ssl.py", line 460, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.3/ssl.py", line 334, in read
v = self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1504)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.3/smtplib.py", line 621, in login
AUTH_PLAIN + " " + encode_plain(user, password))
File "/usr/lib/python3.3/smtplib.py", line 398, in docmd
return self.getreply()
File "/usr/lib/python3.3/smtplib.py", line 370, in getreply
+ str(e))
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1504)
我使用的 SMTP 信息(端口等)来自微软帮助站点,我尝试过的 Outlook 的其他端口或域会导致相同的错误。
的输出openssl version
是1.0.1e 11 Feb 2013