From: W. Trevor King Date: Sat, 19 Jan 2013 18:22:49 +0000 (-0500) Subject: email: Don't assume `extra_headers` has content in get_message() X-Git-Tag: v3.0~18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2217ec5fa589dd0353a05eec0eebf8d43073e34b;p=rss2email.git email: Don't assume `extra_headers` has content in get_message() The default is None, so we should at least handle that case gracefully. Signed-off-by: W. Trevor King --- diff --git a/rss2email/email.py b/rss2email/email.py index 2f6872d..45b105f 100644 --- a/rss2email/email.py +++ b/rss2email/email.py @@ -112,9 +112,10 @@ 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) - for key,value in extra_headers.items(): - encoding = guess_encoding(value, encodings) - message[key] = _Header(value, encoding) + if extra_headers: + for key,value in extra_headers.items(): + encoding = guess_encoding(value, encodings) + message[key] = _Header(value, encoding) return message def smtp_send(sender, recipient, message, config=None, section='DEFAULT'):