}
# read headers and body
+$lnum = 0;
while(<STDIN>) {
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);
}
$header{$lastheader} .= $_;
}
elsif (!$_) { last; }
+ $lnum++;
}
while(<STDIN>) {
$body .= $_;
# 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;
}