R. David Murray writes [1]:
> In 2.x that will work, and will give you the 8bit CTE at need, as
> long as you pass encoded text to MIMEText (as opposed to
> unicode...which it doesn't really handle correctly if I recall
> right).
See also, [2].
[1]: http://bugs.python.org/issue12552
email.MIMEText overide BASE64 for utf8 charset
[2]: http://bugs.python.org/issue12553
Add support for using a default CTE of '8bit' to MIMEText
Signed-off-by: W. Trevor King <wking@tremily.us>
del message['Content-Transfer-Encoding']
charset = _Charset(body_encoding)
charset.body_encoding = _email_encoders.encode_7or8bit
- message.set_payload(body, charset=charset)
+ message.set_payload(body.encode(body_encoding), charset=charset)
if extra_headers:
for key,value in extra_headers.items():
encoding = guess_encoding(value, encodings)