2
我想從python使用hotmail smtp服務器。但是,我的登錄嘗試引起了明顯的SSL3版本號錯誤。我如何更改我正在使用的版本,以及我如何調查此問題?Hotmail SSL3版本號錯誤使用smtp
>> s.connect('smtp.live.com:587')
(220,
'BLU0-SMTP46.phx.gbl Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Tue, 2 Jul 2013 12:15:57 -0700')
>> s.ehlo()
(250,
'BLU0-SMTP46.phx.gbl Hello [123.456.789.01]\nTURN\nSIZE 41943040\nETRN\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\n8bitmime\nBINARYMIME\nCHUNKING\nVRFY\nTLS\nSTARTTLS\nOK')
s.starttls()
(220, '2.0.0 SMTP server ready')
>> s.login('[email protected]','MyPaSsW0rD')
---------------------------------------------------------------------------
SMTPServerDisconnected Traceback (most recent call last)
<ipython-input-48-c8e9d7577d8d> in <module>()
----> 1 s.login('[email protected]','myPassw0rd')
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.pyc in login(self, user, password)
600 elif authmethod == AUTH_PLAIN:
601 (code, resp) = self.docmd("AUTH",
--> 602 AUTH_PLAIN + " " + encode_plain(user, password))
603 elif authmethod == AUTH_LOGIN:
604 (code, resp) = self.docmd("AUTH",
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.pyc in docmd(self, cmd, args)
384 """Send a command, and return its response code."""
385 self.putcmd(cmd, args)
--> 386 return self.getreply()
387
388 # std smtp commands
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.pyc in getreply(self)
357 self.close()
358 raise SMTPServerDisconnected("Connection unexpectedly closed: "
--> 359 + str(e))
360 if line == '':
361 self.close()
SMTPServerDisconnected: Connection unexpectedly closed: [Errno 1] _ssl.c:1363: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
我的SSL版本:
>> import _ssl
>> print _ssl.OPENSSL_VERSION
OpenSSL 1.0.1e 11 Feb 2013
也許這是有關:Python Smtp SSL wrong version on linux
我相信你應該在'starttls()'之後再次'ehlo()'。另外,如果你導入_ssl和print _ssl.OPENSSL_VERSION,你會得到什麼? – rhashimoto
@rhashimoto,我又添加了一個ehlo,它給了我同樣的錯誤。我已經添加了SSL版本信息。 – highBandWidth
我使用Django的默認EmailBackend(當然依賴於smtplib)也有同樣的問題。所以我寫了一個自定義的EmailBackend(基於rhashimoto的答案),可能對其他人碰到這個問題有用! https://github.com/cybercase/django-smtp-starttls – cybercase