Message207018
smtplib has no support for non-ASCII user names in the From to To mail address.
The following two calls fail:
server.rcpt(u"όνομα@example.com"):
File smtplib.py, line 332, in send
s = s.encode("ascii")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
http://hg.python.org/cpython/file/3.3/Lib/smtplib.py#l332
server.rcpt(b'\xcf\x8c\xce\xbd\xce\xbf\xce\xbc\xce\xb1@example.com'):
File email/_parseaddr.py, line 236, in gotonext
if self.field[self.pos] in self.LWS + '\n\r':
TypeError: 'in <string>' requires string as left operand, not int
http://hg.python.org/cpython/file/3.3/Lib/email/_parseaddr.py#l236
There are two ways to solve this:
* Allow users of smptlib to support internationalised email by passing already encoded headers and email addresses. The users is responsible for the encoding and setting the SMTPUTF8 ESMTP option.
* Accept Unicode-encoded email addresses, and convert that to UTF-8 in the library. smtplib is responsible for the encoding and setting the SMTPUTF8 ESMTP option.
References:
https://tools.ietf.org/html/rfc6531: SMTP Extension for Internationalized Email
See also Issue20083, which deals with international domain names in email addresses (the part behind the "@"). This issue deals with the part before the "@".
Note that this is different from RFC 2047, which merely allows non-ASCII encoding in text values in the headers (such as the name of a recipient or the mail subject). |
|
Date |
User |
Action |
Args |
2013-12-28 01:51:55 | macfreek | set | recipients:
+ macfreek |
2013-12-28 01:51:55 | macfreek | set | messageid: <1388195515.33.0.10832843598.issue20084@psf.upfronthosting.co.za> |
2013-12-28 01:51:55 | macfreek | link | issue20084 messages |
2013-12-28 01:51:54 | macfreek | create | |
|