classification
Title: email lib bug
Type: behavior Stage: resolved
Components: email Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Unicode names break email header
View: 34424
Assigned To: Nosy List: SilentGhost, barry, famu xu, mangrisano, r.david.murray
Priority: normal Keywords:

Created on 2019-07-12 12:44 by famu xu, last changed 2019-07-13 14:36 by SilentGhost. This issue is now closed.

Messages (5)
msg347740 - (view) Author: famu xu (famu xu) Date: 2019-07-12 12:44
file: email\_header_value_parser.py

line : encoded_part = part.fold(policy=policy)[:-1] # strip nl
modify to: encoded_part = part.fold(policy=policy)[:-2] # strip nl

because the nl is "\r\n"
msg347741 - (view) Author: famu xu (famu xu) Date: 2019-07-12 12:46
python 3.7 same
msg347751 - (view) Author: Michele Angrisano (mangrisano) * Date: 2019-07-12 18:49
Hi and thank you for opening this issue. 
What is the behaviour?
What is the test you used to reproduce this bug?
msg347826 - (view) Author: famu xu (famu xu) Date: 2019-07-13 14:20
import smtplib
from email.message import EmailMessage
from email.utils import formataddr

server = smtplib.SMTP('smtp.xxx.com',port=25)
server.login('you@xxx.com', 'password')
msg = EmailMessage()

#if address username include Chinese or other multibytes language, it will be encode to utf8 and base64, like '?utf-8?B?6YKu5Lu25rWL6K+V?= <you@xxx.com>', but the raw smtp request data error, "From: xxx" and "To: xxx" fields has the error end char:"\r\r\r\r\n".
#From: ?utf-8?B?6YKu5Lu25rWL6K+V?= <you@xxx.com>\r\r\r\r\n

msg['From'] =formataddr(('中文','you@xxx.com'))
msg['To'] = formataddr(('中文姓名','to@yyy.com'))

msg['Subject'] =subject
msg.set_content('something')

server.send_message(msg)
server.quit()
msg347829 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-07-13 14:36
This seems to be a duplicate of #34424. You'd have to upgrade to the latest 3.7 to get the fix.
History
Date User Action Args
2019-07-13 14:36:15SilentGhostsetstatus: open -> closed

superseder: Unicode names break email header
nosy: + SilentGhost

messages: + msg347829
type: behavior
resolution: duplicate
stage: resolved
2019-07-13 14:20:55famu xusetmessages: + msg347826
2019-07-12 18:49:12mangrisanosetnosy: + mangrisano
messages: + msg347751
2019-07-12 12:46:44famu xusetmessages: + msg347741
2019-07-12 12:44:01famu xucreate