#!/usr/local/bin/perl5 # # This PERL script expects an mbox type file for its input. Its output # is the same mbox file, without any received lines. # # # Version 1.0 # Robert Zeh, September 12, 1998 (razeh@wwa.com) @lines = ; # If we find any of these at the start of a line, we remove the entire line. %strippedWords = ("X-LISTPROCESSOR-VERSION", "YES", "X-AUTHENTICATION-WARNING", "YES", "X-Mailer", "YES", "X-PH", "YES", "PRECEDENCE", "YES", "X-JUNO-LINE-BREAKS", "YES", "X-PRIORITY", "YES", "X-MSMAIL-PRIORITY", "YES", "X-MAILER", "YES", "X-MIMEOLE", "YES", "X-SENDER", "YES", "X-UIDL", "YES", "MIME-VERSION", "YES", "CONTENT-TRANSFER-ENCODING", "YES", "CONTENT-TYPE", "YES"); # If we find any of these at the start of a line, we know that # we have reached the end of a Receive: section. %endOfReceivedWords = ("DATE", "YES", "MESSAGE-ID", "YES", "SUBJECT", "YES", "FROM", "YES", "TO", "YES", "REPLY-TO", "YES", "REFERENCES", "YES", "IN-REPLY-TO", "YES", %strippedWords); for($i = 0; $i < $#lines; $i++) { local($firstWord, $extra) = split(/:/, $lines[$i], 2); if ($firstWord eq "Received") { # Now, try to gobble up all the non blank lines till we hit our # next line that is blank or contains one of the keywords in # endOfReceivedWords $continue = 1; while(($continue) && !($lines[$i] eq "\n")) { local($firstWord, $extra) = split(/:/, $lines[$i], 2); $firstWord = uc($firstWord); if (exists $endOfReceivedWords{uc $firstWord}) { print $lines[$i]; $continue = 0; } if ($continue) { $i++; } } } else { if (!(exists $strippedWords{uc($firstWord)})) { print $lines[$i]; } } }