Email: Fix bug when connecting to SMTP relays that use MD5 auth

This commit is contained in:
Kovid Goyal 2011-01-18 08:48:21 -07:00
parent 4e93f9d761
commit 492fb4c526

View File

@ -554,6 +554,8 @@ class SMTP:
def encode_cram_md5(challenge, user, password):
challenge = base64.decodestring(challenge)
if isinstance(password, unicode): # Added by Kovid, see http://bugs.python.org/issue5285
password = password.encode('utf-8')
response = user + " " + hmac.HMAC(password, challenge).hexdigest()
return encode_base64(response, eol="")