This script will scan email on a mail server and output just the X-Spam-Status headers. Multineline headers are converted to a single line. You can provide a list of files or a directory/*
spamScan.pl dir1/* dir2/* filename etc
#!/usr/bin/perl
use IO::File;
for (@ARGV) {
undef $keep;
$fh = new IO::File $_;
while (<$fh>) {
if (/^X-Spam-Status:/) {
chomp;
($text = $_) =~ s/X-Spam-Status:\s+//;;
$keep = 1;
next;
}
if (defined $keep) {
if (/^\s/) {
chomp;
s/^\s+/ /;
$text .= $_;
} else {
last;
}
}
}
print "$text\n";
}