diff --git a/sendmail/autoreply.pl b/sendmail/autoreply.pl index f6833de88..88bf41259 100755 --- a/sendmail/autoreply.pl +++ b/sendmail/autoreply.pl @@ -29,9 +29,14 @@ if (!$config{'sendmail_path'}) { } # read headers and body +$lnum = 0; while() { s/\r|\n//g; - if (/^(\S+):\s+(.*)/) { + if (/^From\s+(\S+)/ && $lnum == 0) { + # Magic From line + $fromline = $1; + } + elsif (/^(\S+):\s+(.*)/) { $header{lc($1)} = $2; $lastheader = lc($1); } @@ -39,6 +44,7 @@ while() { $header{$lastheader} .= $_; } elsif (!$_) { last; } + $lnum++; } while() { $body .= $_; @@ -55,7 +61,8 @@ if ($header{'x-mailing-list'} || # Do nothing if post is from a mailing list exit 0; } -if ($header{'from'} =~ /postmaster|mailer-daemon/i) { +if ($header{'from'} =~ /postmaster|mailer-daemon/i || + $fromline =~ /postmaster|mailer-daemon|<>/ ) { # Do nothing if post is a bounce exit 0; }