From: eldy <> Date: Fri, 20 Feb 2004 19:43:54 +0000 (+0000) Subject: maillogconvert.pl: Some records were discarded when a "reject" without "to" was found... X-Git-Tag: AWSTATS_6_1_BETA~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a2090f33a0fdf3d0ca6c0594fcf0086acdec27e;p=thirdparty%2FAWStats.git maillogconvert.pl: Some records were discarded when a "reject" without "to" was found on same line with postfix. --- diff --git a/docs/awstats_changelog.txt b/docs/awstats_changelog.txt index 374a3b7e..dcef9de4 100644 --- a/docs/awstats_changelog.txt +++ b/docs/awstats_changelog.txt @@ -9,6 +9,7 @@ Fixes: - Fixed a problem of not working misc feature when using IIS and when URLWithQuery was set to 0. - maillogconvert.pl: Better management of error records with sendmail. + and postfix (some "reject" records were discarded). - Now all non ISO-8859-1 languages are shown correctly even with Apache2 whatever is the value of the AddDefaultCharset directive. diff --git a/tools/maillogconvert.pl b/tools/maillogconvert.pl index efd7381a..337df843 100644 --- a/tools/maillogconvert.pl +++ b/tools/maillogconvert.pl @@ -248,17 +248,24 @@ while (<>) { # postfix: Jan 01 04:19:04 apollon postfix/smtpd[26553]: 1954F3B8A4: reject: RCPT from unknown[80.245.33.2]: 450 : User unknown in local recipient table; from= to= proto=ESMTP helo= # postfix: Jan 01 04:26:39 halley postfix/smtpd[9245]: reject: RCPT from unknown[203.156.32.33]: 554 : Recipient address rejected: Relay access denied; from=<1126448365@aol.com> to= my ($mon,$day,$time,$id,$code,$from,$to)=m/(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+[\w\-]+\s+(?:postfix\/(?:local|lmtp|smtpd|smtp|virtual|pipe))\[\d+\]:\s+(.*?):\s+(.*)\s+from=([^\s,]*)\s+to=([^\s,]*)/; + # postfix: Jan 01 14:10:16 juni postfix/smtpd[2568]: C34ED1432B: reject: RCPT from relay2.tp2rc.edu.tw[163.28.32.177]: 450 : User unknown in local recipient table; from=<> proto=ESMTP helo= + if (! $mon) { ($mon,$day,$time,$id,$code,$from)=m/(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+[\w\-]+\s+(?:postfix\/(?:local|lmtp|smtpd|smtp|virtual|pipe))\[\d+\]:\s+(.*?):\s+(.*)\s+from=([^\s,]*)/; } $mailid=($id eq 'reject'?'999':$id); # id not provided in log, we take '999' - # $code='reject: RCPT from c66.191.66.89.dul.mn.charter.com[66.191.66.89]: 450 : User unknown in local recipient table;' - # or 'reject: RCPT from unknown[203.156.32.33]: 554 : Recipient address rejected: Relay access denied;' if ($mailid) { + # $code='reject: RCPT from c66.191.66.89.dul.mn.charter.com[66.191.66.89]: 450 : User unknown in local recipient table;' + # or 'reject: RCPT from unknown[203.156.32.33]: 554 : Recipient address rejected: Relay access denied;' if ($code =~ /\s+(\d\d\d)\s+/) { $mail{$mailid}{'code'}=$1; } else { $mail{$mailid}{'code'}=999; } # Unkown error - if (! $mail{$mailid}{'relay_s'} && $code =~ /from\s+([^\s]+)\s+/) { + if (! $mail{$mailid}{'relay_s'} && $code =~ /from\s+([^\s]+)\s+/) { $mail{$mailid}{'relay_s'}=&trim($1); } $mail{$mailid}{'from'}=&trim($from); - $mail{$mailid}{'to'}=&trim($to); + if ($to) { + $mail{$mailid}{'to'}=&trim($to); + } + elsif ($code =~ /<(.*)>/) { + $mail{$mailid}{'to'}=&trim($1); + } $mail{$mailid}{'mon'}=$mon; $mail{$mailid}{'day'}=$day; $mail{$mailid}{'time'}=$time;