--- postgrey.old 2008-05-22 17:36:15.000000000 +1000 +++ postgrey 2008-05-22 18:07:29.000000000 +1000 @@ -146,11 +146,29 @@ my ($user, $domain) = split(/@/, $addr, 2); defined $domain or return $addr; + + # BATV is defined as prvs=tag-val=loc-core@, but sometimes shows up + # as prvs=loc-core=tag-val@... + if ($user =~ /^prvs=/) { + my @a = split(/=/, $user); + if ($#a == 2) { + if ($a[1] =~ /^[0-9a-z]{10}/ && $a[2] !~ /^[0-9a-z]{10}/) { + $user = $a[2]; + } elsif ($a[2] =~ /^[0-9a-z]{10}/ && $a[1] !~ /^[0-9a-z]{10}/) { + $user = $a[1]; + } else { + # throw a coin, pick the standard + $user = $a[2]; + } + } + } + # strip extension, used sometimes for mailing-list VERP $user =~ s/\+.*//; # replace numbers in VERP addresses with '#' so that # we don't create a new key for each mail $user =~ s/\b\d+\b/#/g; + return "$user\@$domain"; }