From: W. Trevor King Date: Thu, 24 Jan 2013 05:30:04 +0000 (-0500) Subject: email: Encode the body when we might use 8bit encoding X-Git-Tag: v3.0~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=75752e094c71f2574b27f2723ea7bde12aa3f7e4;p=rss2email.git email: Encode the body when we might use 8bit encoding 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 --- diff --git a/rss2email/email.py b/rss2email/email.py index 8bf3eb6..626acda 100644 --- a/rss2email/email.py +++ b/rss2email/email.py @@ -122,7 +122,7 @@ def get_message(sender, recipient, subject, body, content_type, 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)