New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
smtplib is broken in Python3 #49509
Comments
Issue #<3921> may be the same problem. Sending Gmail by smtplib fails on Python 3.0 and 3.0.1.
# original version
def encode_plain(user, password):
return encode_base64("\0%s\0%s" % (user, password))
# fixed version. Note that "eol=''" is given in Python 2.6's smtplib.
def encode_plain(user, password):
s = "\0%s\0%s" % (user, password)
return encode_base64(s.encode('ascii'), eol='') |
Can you show us the failing application? Most likely, the bug is in your |
The attached test script works fine in Python 2.6. Replace the following texts in the script: |
The attachment is output of smtptest.py on Python 3.0. |
sorry, pressed the wrong button. that solution does work. didn't find this until #python helped me get: return encode_base64( ("\0%s\0%s" % (user, password) ).encode('ascii') ) |
I add simple smtp auth unit test to exercise this bug. |
Martin: see a test script in bpo-3921. |
5304 and 3921 are fixed. Is there still an issue here? If so, I think |
Looks like I accidentally deleted the file I was asking for. Not sure |
There is a similar problem that I found with encode_cram_md5 in I do not know if I did things correctly, but just in case it can help def encode_cram_md5(challenge, user, password):
challenge = base64.decodestring(challenge)
#response = user + " " + hmac.HMAC(password,
challenge).hexdigest()
response = user + " " + hmac.HMAC(password.encode(),
challenge).hexdigest()
#return encode_base64(response)
return encode_base64((response).encode('ascii'), eol='')
def encode_plain(user, password):
#return encode_base64("\0%s\0%s" % (user, password))
return encode_base64(("\0%s\0%s" % (user, password)).encode
('ascii'), eol='') |
Committed the simple auth tests and fix in r72868 in py3k and r72877 in Now we need tests for the other auth cases. |
LOGIN and CRAM-MD5 login are fixed in r72990 (3.1) and r72991 (3.0). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: