diff options
| author | bwarsaw | 2002-10-05 07:28:07 +0000 |
|---|---|---|
| committer | bwarsaw | 2002-10-05 07:28:07 +0000 |
| commit | 2bf00aa187346a260b3053a90e9b50ab69c34d46 (patch) | |
| tree | 1c62d3e07bffcae63cd4835868c8792f6d034403 | |
| parent | cb8c40cf68e70afcd36d6e6c55ec4d1d1dbcdb73 (diff) | |
| download | mailman-2bf00aa187346a260b3053a90e9b50ab69c34d46.tar.gz mailman-2bf00aa187346a260b3053a90e9b50ab69c34d46.tar.zst mailman-2bf00aa187346a260b3053a90e9b50ab69c34d46.zip | |
_dispose(): Possibly forward the message in two situations: if the
message did not bounce match, or if no member addresses could be
extracted from it.
maybe_forward(): MIME Forward the given message to the list owner +
list moderator, if bounce_unrecognized_goes_to_list_owner is true.
Otherwise it discards the message. Write a log entry in either case.
| -rw-r--r-- | Mailman/Queue/BounceRunner.py | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/Mailman/Queue/BounceRunner.py b/Mailman/Queue/BounceRunner.py index e8109d746..8face3653 100644 --- a/Mailman/Queue/BounceRunner.py +++ b/Mailman/Queue/BounceRunner.py @@ -17,15 +17,19 @@ """Bounce queue runner.""" import re +from email.MIMEText import MIMEText +from email.MIMEMessage import MIMEMessage from email.Utils import parseaddr from Mailman import mm_cfg from Mailman import Utils from Mailman import LockFile +from Mailman.Message import UserNotification from Mailman.Bouncers import BouncerAPI from Mailman.Queue.Runner import Runner from Mailman.Queue.sbcache import get_switchboard from Mailman.Logging.Syslog import syslog +from Mailman.i18n import _ COMMASPACE = ', ' @@ -72,22 +76,7 @@ class BounceRunner(Runner): # If that still didn't return us any useful addresses, then send it on # or discard it. if not addrs: - # Does the list owner want to get non-matching bounce messages? - # If not, simply discard it. - if mlist.bounce_unrecognized_goes_to_list_owner: - syslog('bounce', 'forwarding unrecognized, message-id: %s', - msg.get('message-id', 'n/a')) - # Be sure to point the envelope sender at the site owner for - # any bounces to list owners. - recips = mlist.owner[:] - recips.extend(mlist.moderator) - outq.enqueue(msg, msgdata, - recips=recips, - envsender=Utils.get_site_email(extra='admin'), - ) - else: - syslog('bounce', 'discarding unrecognized, message-id: %s', - msg.get('message-id', 'n/a')) + maybe_forward(mlist, msg, msgdata, outq) return # BAW: It's possible that there are None's in the list of addresses, # although I'm unsure how that could happen. Possibly ScanMessages() @@ -140,6 +129,7 @@ class BounceRunner(Runner): # these, but do log it. syslog('bounce', 'bounce message with non-members: %s', COMMASPACE.join(addrs)) + maybe_forward(mlist, msg, msgdata, outq) @@ -172,3 +162,33 @@ def verp_bounce(mlist, msg): mm_cfg.VERP_REGEXP) return [] return [addr] + + + +def maybe_forward(mlist, msg, msgdata, outq): + # Does the list owner want to get non-matching bounce messages? + # If not, simply discard it. + if mlist.bounce_unrecognized_goes_to_list_owner: + recips = mlist.owner[:] + recips.extend(mlist.moderator) + # Wrap the message as an attachment + text = MIMEText(Utils.wrap(_("""\ +The attached message was received as a bounce, but either the bounce format +was not recognized, or no member addresses could be extracted from it. You, +as the list administrators have requested to receive all unrecognized bounce +messages. + +""")), + _charset=Utils.GetCharSet(mlist.preferred_language)) + attachment = MIMEMessage(msg) + notice = UserNotification(recips, mlist.GetBouncesEmail(), + _('Uncaught bounce notification')) + notice.set_type('multipart/mixed') + notice.attach(text) + notice.attach(attachment) + notice.send(mlist) + syslog('bounce', 'forwarding unrecognized, message-id: %s', + msg.get('message-id', 'n/a')) + else: + syslog('bounce', 'discarding unrecognized, message-id: %s', + msg.get('message-id', 'n/a')) |
