--- /c/Python35/Lib/smtplib-old.py Tue Aug 25 04:13:18 2015 +++ /c/Python35/Lib/smtplib.py Tue Oct 20 23:11:56 2015 @@ -38,6 +38,8 @@ # Better RFC 821 compliance (MAIL and RCPT, and CRLF in data) # by Carey Evans , for picky mail servers. # RFC 2554 (authentication) support by Gerhard Haering . +# Fix authentication with mechanism AUTH LOGIN by +# Oliver Merkel . # # This was modified from the Python 1.5 library HTTP lib. @@ -627,7 +629,10 @@ initial_response = (authobject() if initial_response_ok else None) if initial_response is not None: response = encode_base64(initial_response.encode('ascii'), eol='') - (code, resp) = self.docmd("AUTH", mechanism + " " + response) + if mechanism == 'LOGIN': + (code, resp) = self.docmd(response) + else: + (code, resp) = self.docmd("AUTH", mechanism + " " + response) else: (code, resp) = self.docmd("AUTH", mechanism) # Server replies with 334 (challenge) or 535 (not supported) @@ -657,7 +662,7 @@ def auth_login(self, challenge=None): """ Authobject to use with LOGIN authentication. Requires self.user and self.password to be set.""" - (code, resp) = self.docmd( + (code, resp) = self.docmd("AUTH", "LOGIN " + encode_base64(self.user.encode('ascii'), eol='')) if code == 334: return self.password