diff options
| author | Aurélien Bompard | 2015-12-09 09:14:27 +0100 |
|---|---|---|
| committer | Barry Warsaw | 2015-12-12 17:23:20 -0500 |
| commit | c972f9d5504469890ba72e81cd662d18f1ee4c13 (patch) | |
| tree | 8e014977b7ba6aa59854c03a84d1316932e3534a /src/mailman/chains/reject.py | |
| parent | 75fe5e81e91b68991b16b15843802545da6d38de (diff) | |
| download | mailman-c972f9d5504469890ba72e81cd662d18f1ee4c13.tar.gz mailman-c972f9d5504469890ba72e81cd662d18f1ee4c13.tar.zst mailman-c972f9d5504469890ba72e81cd662d18f1ee4c13.zip | |
Diffstat (limited to 'src/mailman/chains/reject.py')
| -rw-r--r-- | src/mailman/chains/reject.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mailman/chains/reject.py b/src/mailman/chains/reject.py index bbf57270c..8e14385ba 100644 --- a/src/mailman/chains/reject.py +++ b/src/mailman/chains/reject.py @@ -26,12 +26,15 @@ import logging from mailman.app.bounces import bounce_message from mailman.chains.base import TerminalChainBase +from mailman.core.errors import RejectMessage from mailman.core.i18n import _ from mailman.interfaces.chain import RejectEvent from zope.event import notify log = logging.getLogger('mailman.vette') + +NEWLINE = '\n' SEMISPACE = '; ' @@ -53,7 +56,21 @@ class RejectChain(TerminalChainBase): rule_misses = msgdata.get('rule_misses') if rule_misses: msg['X-Mailman-Rule-Misses'] = SEMISPACE.join(rule_misses) - # XXX Exception/reason - bounce_message(mlist, msg) + reasons = msgdata.get('moderation_reasons') + if reasons is None: + error = None + else: + error = RejectMessage(_(""" +Your message to the {list_name} mailing-list was rejected for the following +reasons: + +{reasons} + +The original message as received by Mailman is attached. +""").format( + list_name=mlist.display_name, + reasons=NEWLINE.join(reasons) + )) + bounce_message(mlist, msg, error) log.info('REJECT: %s', msg.get('message-id', 'n/a')) notify(RejectEvent(mlist, msg, msgdata, self)) |
