From: Dmitry Bogatov Date: Wed, 23 Jan 2013 20:35:04 +0000 (+0400) Subject: Add 8bit Content-Transfer-Encoding support. X-Git-Tag: v3.0~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bdf670277bc9a73d5010438b2b650cf5f7387dad;p=rss2email.git Add 8bit Content-Transfer-Encoding support. Signed-off-by: Dmitry Bogatov --- diff --git a/rss2email/config.py b/rss2email/config.py index 0daa979..4dfce42 100644 --- a/rss2email/config.py +++ b/rss2email/config.py @@ -52,6 +52,9 @@ CONFIG['DEFAULT'] = _collections.OrderedDict(( ### Addressing # The email address messages are from by default ('from', 'user@rss2email.invalid'), + # Transfer-Encoding. For local mailing it is safe and + # convient to use 8bit. + ('use_8bit', str(True)), # True: Only use the 'from' address. # False: Use the email address specified by the feed, when possible. ('force-from', str(False)), diff --git a/rss2email/email.py b/rss2email/email.py index 45b105f..005b68a 100644 --- a/rss2email/email.py +++ b/rss2email/email.py @@ -112,6 +112,9 @@ def get_message(sender, recipient, subject, body, content_type, message['From'] = _formataddr((sender_name, sender_addr)) message['To'] = _formataddr((recipient_name, recipient_addr)) message['Subject'] = _Header(subject, subject_encoding) + if config.getboolean(section, 'use_8bit'): + message['Content-Transfer-Encoding'] = '8bit' + message.set_payload(body) if extra_headers: for key,value in extra_headers.items(): encoding = guess_encoding(value, encodings) @@ -160,7 +163,8 @@ def sendmail_send(sender, recipient, message, config=None, section='DEFAULT'): ['/usr/sbin/sendmail', recipient], stdin=_subprocess.PIPE, stdout=_subprocess.PIPE, stderr=_subprocess.PIPE) - stdout,stderr = p.communicate(message.as_string().encode('ascii')) + stdout,stderr = p.communicate(message.as_string() + .encode(str(message.get_charset()))) status = p.wait() if status: raise _error.SendmailError(