You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
assignee='https://github.com/bitdancer'closed_at=<Date2009-05-28.18:51:52.597>created_at=<Date2009-02-14.14:19:17.380>labels= ['easy', 'type-bug', 'library']
title='smtplib is broken in Python3'updated_at=<Date2009-05-28.18:52:20.443>user='https://bugs.python.org/miwa'
Sending Gmail by smtplib fails on Python 3.0 and 3.0.1.
It seems to be exist two problems in encode_plain function in smtplib.py:
parameter of encode_base64 must be bytes, not str,
by default, encode_base64 adds extra newline.
The following is an example of patch.
# original versiondefencode_plain(user, password):
returnencode_base64("\0%s\0%s"% (user, password))
# fixed version. Note that "eol=''" is given in Python 2.6's smtplib.defencode_plain(user, password):
s="\0%s\0%s"% (user, password)
returnencode_base64(s.encode('ascii'), eol='')
5304 and 3921 are fixed. Is there still an issue here? If so, I think
we need a test case we can add to the test suite. It can be a patch
against the new test_smtpnet.py test.
There is a similar problem that I found with encode_cram_md5 in
smtplib.py, SMTP.login() method. I used the solution proposed by miwa,
both for PLAIN and CRAM MD5 authentication. Additionally, for the last
one, I had to introduce a second correction and byte encode the
password string when passing it to hmac.HMAC.
I do not know if I did things correctly, but just in case it can help
here is the complete patch that I used and worked well with the two
AUTH methods. I keep the original and modified lines for clarity.
Committed the simple auth tests and fix in r72868 in py3k and r72877 in
3.0. Also added the test to trunk in r72878 to keep the test source in
sync, and to 26maint similarly in r72886.
Activity
miwa commentedon Feb 14, 2009
Issue #<3921> may be the same problem.
Sending Gmail by smtplib fails on Python 3.0 and 3.0.1.
It seems to be exist two problems in encode_plain function in smtplib.py:
The following is an example of patch.
loewis commentedon Feb 14, 2009
Can you show us the failing application? Most likely, the bug is in your
code, not in Python.
kalevi commentedon Feb 14, 2009
The attached test script works fine in Python 2.6.
Replace the following texts in the script:
[email protected]
[email protected]
password
miwa commentedon Feb 15, 2009
The attachment is output of smtptest.py on Python 3.0.
[-]smtplib is broken in Python3[/-][+]gmail smtp[/+]toastedrobot commentedon Feb 18, 2009
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') )
[-]gmail smtp[/-][+]smtplib is broken in Python3[/+]marcinbachry commentedon Apr 25, 2009
I add simple smtp auth unit test to exercise this bug.
devdanzin commentedon Apr 25, 2009
Martin: see a test script in bpo-3921.
bitdancer commentedon May 23, 2009
5304 and 3921 are fixed. Is there still an issue here? If so, I think
we need a test case we can add to the test suite. It can be a patch
against the new test_smtpnet.py test.
bitdancer commentedon May 23, 2009
Looks like I accidentally deleted the file I was asking for. Not sure
how that happened, but I'm reattaching it.
jlcaceres commentedon May 23, 2009
There is a similar problem that I found with encode_cram_md5 in
smtplib.py, SMTP.login() method. I used the solution proposed by miwa,
both for PLAIN and CRAM MD5 authentication. Additionally, for the last
one, I had to introduce a second correction and byte encode the
password string when passing it to hmac.HMAC.
I do not know if I did things correctly, but just in case it can help
here is the complete patch that I used and worked well with the two
AUTH methods. I keep the original and modified lines for clarity.
bitdancer commentedon May 24, 2009
Committed the simple auth tests and fix in r72868 in py3k and r72877 in
3.0. Also added the test to trunk in r72878 to keep the test source in
sync, and to 26maint similarly in r72886.
Now we need tests for the other auth cases.
bitdancer commentedon May 28, 2009
LOGIN and CRAM-MD5 login are fixed in r72990 (3.1) and r72991 (3.0).