Issue 33741: UnicodeEncodeError onsmtplib.login(MAIL_USER, MAIL_PASSWORD) (original) (raw)

Issue33741

Created on 2018-06-02 22:40 by JustAnother1, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8938 open Windson Yang,2018-08-26 07:29
Messages (5)
msg318517 - (view) Author: Lars Pötter (JustAnother1) Date: 2018-06-02 22:40
if the password contains non ascii characters then the login fails: >>> smtObj.login(MAIL_USER, MAIL_PASSWORD) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.5/smtplib.py", line 720, in login initial_response_ok=initial_response_ok) File "/usr/lib/python3.5/smtplib.py", line 637, in auth authobject(challenge).encode('ascii'), eol='') File "/usr/lib/python3.5/smtplib.py", line 650, in auth_cram_md5 self.password.encode('ascii'), challenge, 'md5').hexdigest() UnicodeEncodeError: 'ascii' codec can't encode character '' in position : ordinal not in range(128)
msg319205 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-10 08:29
Is this a bug? Are passwords containing non-ASCII characters supposed to be supported? If so, which encoding should be assumed for the password? Since it needs to be base64-encoded, it must be encoded into bytes.
msg319212 - (view) Author: Lars Pötter (JustAnother1) Date: 2018-06-10 12:04
I wanted to login to an existing account so the password works OK in Thunderbird. Here in Germany it is recommended for safe passwords to use the German umlauts(ßÄÖÜäöü). So code page 437 vs 850 or UTF-8 ? If I could pass in the bytes then I could figure out the correct encoding myself.(Try and error) I suppose that in other regions people want to use other encodings. And as long as the encoding is the same when setting the password and transmitting the password then everything is fine, right?
msg319216 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-10 12:34
We definitely need an expert to weigh in on this.
msg319221 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-06-10 14:14
Duplicate of #29750. TLDR: smtplib needs to be fixed to handle binary passwords, and probably to use utf-8 as the default encoding for unicode passwords.
History
Date User Action Args
2022-04-11 14:59:01 admin set github: 77922
2018-08-26 07:29:09 Windson Yang set pull_requests: + <pull%5Frequest8410>
2018-06-10 14:14:35 r.david.murray set status: open -> closedsuperseder: smtplib doesn't handle unicode passwordsnosy: + r.david.murraymessages: + resolution: duplicatestage: resolved
2018-06-10 12:34:03 taleinat set nosy: + giampaolo.rodolamessages: +
2018-06-10 12:04:23 JustAnother1 set messages: +
2018-06-10 08:29:48 taleinat set nosy: + taleinatmessages: +
2018-06-02 22:40:36 JustAnother1 create