[Mimedefang] Accessing Subject in SpamAssassin line?

listuser at neo.pittstate.edu listuser at neo.pittstate.edu
Mon Nov 25 17:11:01 EST 2002


On 25 Nov 2002, Russ GilmanHunt wrote:

> I'm converting from a fairly "pure" SA installation to a MD->SA
> installation, and I've about 25 users to support (nothing too
> strenuous). Many of them have a filter set up for "SPAM" in the subject
> line. How do I add "***SPAM***" to the subject line of the emails? I've
> tried  this:
> 
> action_change_header("Subject", "***** SPAM ***** $Subject");
> 
> But it doesn't seem to be pulling in any Subject line.  Is there a
> global variable set at that point?

I'm doing something that's a little different than what you're doing but
you can easily adapt it.  ...  Actually, on second thought, I'm going to
attach it rather than inline quote it.  Wrapping is horrible.

Ok, skip down to line 30.  My reasoning is that I only want to tag the
subject line if the score is >= 10.  But I want to score everything
regardless.  Yes, the 2nd to last else statment doesn't match the rest.  I
haven't got around to changing that yet.  You can use my logic if you
like.  Your code actually looks fine.  You'd want to include it where I
add X-Spam-Score and X-Spam-Report (the report requires the 3 lines in the
accompaning if statement further up).  

HTH

justin
-------------- next part --------------
sub filter_end ($) {
    my($entity) = @_;

    # If you want quarantine reports, uncomment next line
    # send_quarantine_notifications();

    # No sense doing any extra work
    return if message_rejected();

    # Spam checks if SpamAssassin is installed
    if ($Features{"SpamAssassin"}) {
	if (-s "./INPUTMSG" < 100*1024) {
	    # Only scan messages smaller than 100kB.  Larger messages
	    # are extremely unlikely to be spam, and SpamAssassin is
	    # dreadfully slow on very large messages.
	    my($hits, $req, $names, $report) = spam_assassin_check();
	    if ($hits >= $req) {
                md_log('spam', $hits, $RelayAddr);
		my($score);
		if ($hits < 100) {
		    $score = "*" x int($hits);
		} else {
		    $score = "*" x 40;
		}

		if ($hits >= $req) {
		    my $fixed_report = $report;
 		    $fixed_report =~ s/\n+\z//g;        # fixes for multiline header
		    $fixed_report =~ s/\n/\n\t/g;       # to stop sendmail complaining
		    if ($hits >= 10) {
			action_change_header("Subject", "***SPAM*** $Subject");
		    }
		    action_change_header("X-Spam-Score", "$score ($hits) $names");
		    action_add_header("X-Spam-Report", "$fixed_report");
		} else {
		    action_add_header("X-Spam-Score", "No, $hits ($stars)");
		}
	    } else {
		# Delete any existing X-Spam-Score header?
		action_delete_header("X-Spam-Score");
	    }
	}
    }
}


More information about the MIMEDefang mailing list