#! /usr/bin/perl # Get arguments $class = $ARGV[0] || die; shift; $sender = $ARGV[0] || die; shift; $recip = $ARGV[0] || die; shift; if ($recip =~ /^(spam|ham)-(\w+)@/) { # username is part of the recipient $user = $2; } elsif ($sender =~ /^(\w+)@/) { # username is in the sender $user = $1; } else { print "Can't determine user\n"; exit 75; # EX_TEMPFAIL } # Pull out DSPAM signatures and send them to the dspam program while (<>) { if ((! $subj) && (/^Subject: /)) { $subj = $_; } elsif (/(!DSPAM:[a-f0-9]+!)/) { open(F, "|/usr/local/bin/dspam --source=error --class=$class --user $user"); print F "$subj\n$1\n"; close(F); } elsif (/(X-DSPAM-Signature: [a-f0-9]+)/) { open(F, "|/usr/local/bin/dspam --source=error --class=$class --user $user"); print F "$subj\n$1\n"; close(F); } }