#!/usr/bin/perl
# this little script will take an mbox format file and feeds it to spamfirewall one message at a time


$infile = $ARGV[0];
$mailcounter = 1;
open OUT, ">/tmp/spamfirewalltempfile";
open IN, "<$infile";
  while ($line = <IN>) {
    if (($line =~ /^From\ /) && ($prevline =~ /\s+/)) {
      close OUT;
      print "Sending a file to spamfilter...\n";
      system "cat /tmp/spamfirewalltempfile | /usr/local/bin/spamfirewall 1 &>/dev/null";
      open OUT, ">/tmp/spamfirewalltempfile";
    }
    $prevline = $line;
    print OUT $line;
  }
close IN;
close OUT;