Implementing a slightly tweaked version of Glen and TonyH's fix for mangled content part separators in multiplart messages.
- Legacy-Id: 2649
This commit is contained in:
parent
5d5b88ad38
commit
27e0a62b09
|
@ -13,13 +13,16 @@ def send_scheduled_announcement(announcement):
|
|||
if announcement.replyto:
|
||||
extra['Reply-To'] = announcement.replyto
|
||||
|
||||
content_type = announcement.content_type.lower()
|
||||
if not content_type or 'text/plain' in content_type:
|
||||
# announcement.content_type can contain a case-sensitive parts separator,
|
||||
# so we need to keep it as is, not lowercased, but we want a lowercased
|
||||
# version for the coming comparisons.
|
||||
content_type_lowercase = announcement.content_type
|
||||
if not content_type or 'text/plain' in content_type_lowercase:
|
||||
send_mail_text(None, announcement.to_val, announcement.from_val, announcement.subject,
|
||||
body, cc=announcement.cc_val, bcc=announcement.bcc_val)
|
||||
elif 'multipart' in content_type:
|
||||
# make body a real message so we can parse it
|
||||
body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % content_type) + body
|
||||
elif 'multipart/' in content_type_lowercase:
|
||||
# make body a real message so we can parse it.
|
||||
body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % announcement.content_type) + body
|
||||
|
||||
msg = email.message_from_string(body.encode("utf-8"))
|
||||
send_mail_mime(None, announcement.to_val, announcement.from_val, announcement.subject,
|
||||
|
|
Loading…
Reference in a new issue