New submission from Freek Dijkstra:
smtplib has limited support for non-ASCII domain names in the From to To mail
address. It only works for punycode-encoded domain names, submitted as unicode
string (e.g. server.rcpt(u"[email protected]").
The following two calls fail:
server.rcpt(u"user@пример.ru"):
File smtplib.py, line 332, in send
s = s.encode("ascii")
UnicodeEncodeError: 'ascii' codec can't encode character '\u03c0' in position
19: ordinal not in range(128)
http://hg.python.org/cpython/file/3.3/Lib/smtplib.py#l332
server.rcpt(b"[email protected]"):
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 three ways to solve this (from trivial to complex):
* Make it clear in the documentation what type of input is expected.
* Accept punycode-encoded domain names in email addresses, either in string or
binary format.
* Accept Unicode-encoded domain names, and do the punycode encoding in the
smtplib if required.
See also
References:
https://tools.ietf.org/html/rfc5891: Internationalized Domain Names in
Applications (IDNA): Protocol
----------
components: Library (Lib)
messages: 207017
nosy: macfreek
priority: normal
severity: normal
status: open
title: smtplib: support for IDN (international domain names)
type: enhancement
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20083>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com