aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/Handlers
diff options
context:
space:
mode:
authorMark Sapiro <mark@msapiro.net>2015-01-23 17:35:45 -0800
committerMark Sapiro <mark@msapiro.net>2015-01-23 17:35:45 -0800
commit6d0614d1b0d227b867b47ad133f7c8d2943d52f1 (patch)
treedf9de2462661a7b60ec54d052deca57c2fa02d6e /Mailman/Handlers
parent792407be592b8e7d523cb134a01b09101cbc2cad (diff)
downloadmailman2-6d0614d1b0d227b867b47ad133f7c8d2943d52f1.tar.gz
mailman2-6d0614d1b0d227b867b47ad133f7c8d2943d52f1.tar.xz
mailman2-6d0614d1b0d227b867b47ad133f7c8d2943d52f1.zip
Implemented dmarc_wrapped_message_text to optionally add an explanitory
text/plain part to a message wrapped via dmarc_moderation_action.
Diffstat (limited to 'Mailman/Handlers')
-rw-r--r--Mailman/Handlers/WrapMessage.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/Mailman/Handlers/WrapMessage.py b/Mailman/Handlers/WrapMessage.py
index 0e47e1e4..83f521fb 100644
--- a/Mailman/Handlers/WrapMessage.py
+++ b/Mailman/Handlers/WrapMessage.py
@@ -24,6 +24,9 @@ original message.
import copy
+from email.MIMEMessage import MIMEMessage
+from email.MIMEText import MIMEText
+
from Mailman import Utils
# Headers from the original that we want to keep in the wrapper.
@@ -63,12 +66,23 @@ def process(mlist, msg, msgdata):
if key.lower() not in KEEPERS:
del msg[key]
msg['MIME-Version'] = '1.0'
- msg['Content-Type'] = 'message/rfc822'
- msg['Content-Disposition'] = 'inline'
msg['Message-ID'] = Utils.unique_message_id(mlist)
# Add the headers from CookHeaders.
for k, v in msgdata['add_header'].items():
msg[k] = v
- # And set the payload the way email parses it.
- msg.set_payload([omsg])
+ # Are we including dmarc_wrapped_message_text? I.e., do we have text and
+ # are we wrapping because of dmarc_moderation_action?
+ if mlist.dmarc_wrapped_message_text and msgdata.get('from_is_list') == 2:
+ part1 = MIMEText(Utils.wrap(mlist.dmarc_wrapped_message_text),
+ 'plain',
+ Utils.GetCharSet(mlist.preferred_language))
+ part1['Content-Disposition'] = 'inline'
+ part2 = MIMEMessage(omsg)
+ part2['Content-Disposition'] = 'inline'
+ msg['Content-Type'] = 'multipart/mixed'
+ msg.set_payload([part1, part2])
+ else:
+ msg['Content-Type'] = 'message/rfc822'
+ msg['Content-Disposition'] = 'inline'
+ msg.set_payload([omsg])