Closed rslinckx closed 9 years ago
If it is not supported by all SMTP servers I'm more inclined towards just making everything into bytestrings when passing arguments to the sendmail
functions or even not handling this at all since the email.mime
library seems to handle Unicode headers well enough.
I'm not sure how it turns out when Unicode receivers are specified, could you perhaps show me the stack trace that happened when you tried to send Unicode headers?
Ok I see what you're trying to do here. We will have to enforce Unicode everywhere in all headers for this approach to work. So you might want to write a conversion function that converts between the Unicode and bytes objects.
Headers need to be either byte string or unicode, both will work properly. The receivers arguments of sendmail() needs to be a byte string, and i choose to encode to utf-8 since it's the most 'supported' encoding. Alternative is silently dropping emails that can't be converted to ascii
I agree with you on the decision for utf8, look to the Headers.encoding
attribute for the user specified encoding. Also I don't see why utf8 cannot encode ASCII. Utf8 is backwards-compatible with ASCII.
An alternative I suppose is to be dumb and let the users yield byte strings or header objects, which is IMHO more efficient so I might be going towards that side.
Here is a proposed change. The only thing is does is to encode emails as utf-8 when serializing the RCPT TO command. This isn't supported by all smtp servers, and in theory they should ignore the utf-8 encoded email if they don't. I'm not sure how frequent having an unicode email happens in practice...