homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author macfreek
Recipients macfreek
Date 2013年12月28日.01:49:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1388195363.36.0.929515660511.issue20083@psf.upfronthosting.co.za>
In-reply-to
Content
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"user@xn--e1afmkfd.ru").
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"user@xn--e1afmkfd.ru"):
 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
History
Date User Action Args
2013年12月28日 01:49:23macfreeksetrecipients: + macfreek
2013年12月28日 01:49:23macfreeksetmessageid: <1388195363.36.0.929515660511.issue20083@psf.upfronthosting.co.za>
2013年12月28日 01:49:23macfreeklinkissue20083 messages
2013年12月28日 01:49:21macfreekcreate

AltStyle によって変換されたページ (->オリジナル) /