New submission from Freek Dijkstra: 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\x...@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). ---------- components: Library (Lib) messages: 207018 nosy: macfreek priority: normal severity: normal status: open title: smtplib: support for UTF-8 encoded headers (SMTPUTF8) type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20084> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com