Update of /cvsroot/mailman/mailman/Mailman/Queue
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17461

Modified Files:
      Tag: Release_2_1-maint
        BounceRunner.py 
Log Message:
_dispose(), verp_probe(): Add logic to parse and handle probe bounce verps.


Index: BounceRunner.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Queue/BounceRunner.py,v
retrieving revision 2.27.2.3
retrieving revision 2.27.2.4
diff -u -d -r2.27.2.3 -r2.27.2.4
--- BounceRunner.py     23 Jan 2004 00:26:07 -0000      2.27.2.3
+++ BounceRunner.py     10 Feb 2004 22:52:17 -0000      2.27.2.4
@@ -37,6 +37,12 @@
 
 REGISTER_BOUNCES_EVERY = mm_cfg.minutes(15)
 
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 
 class BounceRunner(Runner):
@@ -82,8 +88,21 @@
         # Try VERP detection first, since it's quick and easy
         addrs = verp_bounce(mlist, msg)
         if not addrs:
+            # See if this was a probe message.
+            token = verp_probe(mlist, msg)
+            if token:
+                # The list must be locked to perform these operations
+                mlist.Lock()
+                try:
+                    op, addr, bmsg = mlist.pend_confirm(token)
+                    info = mlist.getBounceInfo(addr)
+                    mlist.disableBouncingMember(addr, info, bmsg)
+                    mlist.Save()
+                finally:
+                    mlist.Unlock()
+                return
             # That didn't give us anything useful, so try the old fashion
-            # bounce matching modules
+            # bounce matching modules.
             addrs = BouncerAPI.ScanMessages(mlist, msg)
         # If that still didn't return us any useful addresses, then send it on
         # or discard it.
@@ -173,6 +192,41 @@
 
 
 
+def verp_probe(mlist, msg):
+    bmailbox, bdomain = Utils.ParseEmail(mlist.GetBouncesEmail())
+    # Sadly not every MTA bounces VERP messages correctly, or consistently.
+    # Fall back to Delivered-To: (Postfix), Envelope-To: (Exim) and
+    # Apparently-To:, and then short-circuit if we still don't have anything
+    # to work with.  Note that there can be multiple Delivered-To: headers so
+    # we need to search them all (and we don't worry about false positives for
+    # forwarded email, because only one should match VERP_REGEXP).
+    vals = []
+    for header in ('to', 'delivered-to', 'envelope-to', 'apparently-to'):
+        vals.extend(msg.get_all(header, []))
+    for field in vals:
+        to = parseaddr(field)[1]
+        if not to:
+            continue                          # empty header
+        mo = re.search(mm_cfg.VERP_PROBE_REGEXP, to)
+        if not mo:
+            continue                          # no match of regexp
+        try:
+            if bmailbox <> mo.group('bounces'):
+                continue                      # not a bounce to our list
+            # Extract the token and see if there's an entry
+            token = mo.group('token')
+            data = mlist.pend_confirm(token, expunge=False)
+            if data is not None:
+                return token
+        except IndexError:
+            syslog(
+                'error',
+                "VERP_PROBE_REGEXP doesn't yield the right match groups: %s",
+                mm_cfg.VERP_PROBE_REGEXP)
+    return None
+
+
+
 def maybe_forward(mlist, msg):
     # Does the list owner want to get non-matching bounce messages?
     # If not, simply discard it.


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to