]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Parsing fo rBounce-Id in class PostfixLogfileParser
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 10 Apr 2024 12:43:24 +0000 (14:43 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 10 Apr 2024 12:43:24 +0000 (14:43 +0200)
lib/pp_admintools/handler/pflogparse.py

index 9ae7ee846f809ac030abeaea2f5412194ca7d957..97c025705cc7a2587b50eec885f9eac59445d64d 100644 (file)
@@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-__version__ = '0.4.1'
+__version__ = '0.4.2'
 
 
 # =============================================================================
@@ -61,6 +61,8 @@ class PostfixLogfileParser(HandlingObject):
     re_dis_mail = re.compile(r'\smail=(\d+)', re.IGNORECASE)
 
     re_message_id = re.compile(r'message-id=(\S+)', re.IGNORECASE)
+    re_bounce_id = re.compile(
+        r'sender\s+non-delivery\s+notification:\s+(?P<bounce_id>\S+)', re.IGNORECASE)
 
     re_from_addr = re.compile(
         r'^\s*from=<(?P<from>[^>]*)>,\s+size=(?P<size>\d+),\s+nrcpt=(?P<nrcpt>\d+)',
@@ -320,6 +322,14 @@ class PostfixLogfileParser(HandlingObject):
         if smtpd_done:
             return
 
+        if command == 'postfix/bounce':
+            m = self.re_bounce_id.match(message)
+            if m:
+                bid = m['bounce_id'].strip()
+                if bid:
+                    self.chain[postfix_id].add_bounce_id(bid)
+                    return
+
         if self.verbose > 1:
             msg = f'Evaluating further entry of {command!r} for Postfix Id {postfix_id!r}: '
             LOG.debug(msg + message)