famu xu <[email protected]> added the comment:
import smtplib
from email.message import EmailMessage
from email.utils import formataddr
server = smtplib.SMTP('smtp.xxx.com',port=25)
server.login('[email protected]', '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?= <[email protected]>',
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?= <[email protected]>\r\r\r\r\n
msg['From'] =formataddr(('中文','[email protected]'))
msg['To'] = formataddr(('中文姓名','[email protected]'))
msg['Subject'] =subject
msg.set_content('something')
server.send_message(msg)
server.quit()
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37572>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com