I have read tons of emails on how to do this and wanted to do it myself. So
I came up with an easy solution.... edit qmail-scanner-queue.pl :)

Just insert the following code into the Spamassassin subroutine.

############ START HERE #######################
if ($sa_status == 1) {  # Did spamc say it was spam
        my (@RAW,@RAT);
        my ($head_bl,$subject_bl,$mline_bl,$linenum_bl,$spam_subject_bl);
        $spam_subject_bl="**** SPAM ****";   # What Message do you want to
prefix to the message subject
        open(DAT, "$scandir/$wmaildir/new/$file_id");  # Open the current
message for reading
        @RAW=<DAT>;
        close(DAT);

$linenum_bl=0;  # Sloppy code
foreach $mline_bl (@RAW) {
        $linenum_bl=$linenum_bl+1; # Even sloppier
        chomp($mline_bl);
        ($head_bl,$subject_bl)=split(/:/, $mline_bl, 2); # Split each line
of the message into header name and content
                if ($head_bl eq "Subject") { # Is the header name Subject
                &debug("SUBJECT OF SPAMMAIL: $subject_bl"); # Log the spam
email subject
                @RAT[$linenum_bl]="Subject: $spam_subject_bl $subject_bl\n";
# Re-write the subject to include spam prefix
                } else {
                @RAT[$linenum_bl]="$mline_bl\n"; # This if for if the header
name is NOT Subject
                }
}

        open(DAT, ">$scandir/$wmaildir/new/$file_id"); # Open the current
message for over writing
        print DAT @RAT; 
        close(DAT); # Close the current Message
}  # Return to qmail-scanner-queue for qmail-injection... etc
################### END HERE ######################

Yes, I know that my coding is kind of sloppy, but it does the job.

You want to insert this code just above the END of the spammassassin
subroutine where it says:

#####################
  $stop_spamassassin_time=[gettimeofday];
  $spamassassin_time = tv_interval ($start_spamassassin_time,
$stop_spamassassin_time);
  &debug("spamassassin: finished scan of dir \"$scandir/$file_id\" in
$spamassassin_time secs");
}
#####################


Worked excellent from here, did its job and now OE can filter the messages.
I use this now for SITE-WIDE email where I do not want to hassle the users
with server side mail filters (procmail) or stop the mail completely (and
maybe loose some emails).
If anyone can re-write this code better or for faster execution be my guest
as I did this in about 5 mins.

Thanks.

Note: I will be getting my setup guide for qmail + vpopmail + courier-imap +
spamassassin out sometime this week I hope.

Brandon Lehmann
Networld Online Inc.
1243 Napoleon Street
Fremont, OH 43420
419-334-9042
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
www.nwonline.net


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to