From f4e065cfda55dbb471187e5d5a9fa236e5ac2630 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 25 Nov 2020 16:23:54 -1000 Subject: [PATCH] Unwrap SRS e-mail addresses When building statistics from mail servers, messages which where processed by Sender Rewriting Scheme (SRS) are mis-classified as internal mail while they are external, and appear to come from a huge number of different addresses which in fact correspond to the same actual sender. Add a rewriting function that detects such addresses and extract the relevant information from it. --- tools/maillogconvert.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/maillogconvert.pl b/tools/maillogconvert.pl index d5f7b06b..6fb3a8b4 100755 --- a/tools/maillogconvert.pl +++ b/tools/maillogconvert.pl @@ -76,9 +76,15 @@ sub CleanVadminUser { $_=shift||''; return $_; } +sub UnwrapSRS { $_=shift||''; + s/^SRS1=.*=([^=]+)=([^@]+)@.*$/\2@\1/g; + s/^SRS0=[^=]+=[^=]+=([^=]+)=([^@]+)@.*$/\2@\1/g; + return $_; +} + sub CleanEmail { $_=shift||''; s/[#<|>\[\]]//g; # Remove unwanted characters first - return $_; + return &UnwrapSRS($_); } # Clean host addresses -- 2.47.2