Freek Dijkstra added the comment:

Are you sure that issue 8489 is a duplicate? While both concern RFC 6531, the 
patch for 8489 only seems to add test to check how smtplib.SMTP.login() handles 
a username with non-ASCII characters. This issue concerns the 
smtplib.SMTP.rcpt() (and indirectly smtplib.SMTP.send()).

>From your comment in issue 20083 you seem to prefer that all input is in 
>strings, not bytes. I think that is sensible, but it means that smtplib is 
>responsible for doing the encoding, including the UTF-8 encoding instead of 
>ASCII encoding for mails that support the SMTPUTF8 extension.

Would the following be reasonable?

* The smtplib.SMTP class gets a new attribute, header_encoding
* The header_encoding attribute is 'ascii' by default.
* header_encoding is used by the send() method, and perhaps also by the login() 
method, but not by the data() method (for that, a body_encoding sounds more 
reasonable).
* A user may set header_encoding explicitly

Open questions are:

* Should the library automatically set header_encoding to UTF-8? If so, when? 
If the connected server announces the SMTPUTF8 extension?
* What should happen if the users submits non-ASCII data in any of the headers, 
but the server has not announced the SMTPUTF8 extension? Currently, this raises 
a UnicodeEncodeError exception, but I think it should be more explicit that it 
is a combination of Unicode input combined with lack of support from the MTA.

----------

_______________________________________
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

Reply via email to