[Mimedefang] Score additions using filter begin.

Wayne wayne at hamilton.net
Tue Feb 3 18:01:17 EST 2004


Hello,

 I am trying to add points and header information for domains that have no
reverse DNS, are not  .com, .net, .org, .edu, .mil, .gov or have three sets
of numbers with dashes in the RDNS. I know this sounds harsh but it works
for a lot of our customers. My problem is that for some reason some emails
slip through. They are usually .com.ru or sendmail says they may be forged.
Here is my filter_begin and filter_end. Could someone look at it and tell me
how to do it better.

Thanks Wayne

#******************************************************************
#Filter_begin
# Added point for no reverse DNS records.
#
#******************************************************************
sub filter_begin (){
    # Spamassassin tweaks using relay information
    $SA_score_additions = 0;
    $SA_test_additions = "";

    # Prejudice against no rDNS
    if ($RelayHostname =~ /\[$RelayAddr\]/) {
        $SA_score_additions = .98;
        $SA_test_additions .= "###MLSPAM###";
    }
    # Most likely Spam
   if (($RelayHostname !~ /\.com$|\.net$|\.edu$|\.org$|\.gov$|\.mil$/) ||
($RelayHostname =~/\d{1,3}-\d{1,3}-\d{1,3}/)) {
   $SA_score_additions = .98;
   $SA_test_additions .= " ###MLSPAM###";
   }

}
# If SpamAssassin found SPAM, append report.  We do it as a separate
# attachment of type text/plain
sub filter_end {
    my($entity) = @_;

    # 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();
        # add our things
            $hits += $SA_score_additions;
            $names .= $SA_test_additions;

        if ($hits >= 1) {
           my $spamgraph = 'X' x ($hits > 25 ? 25: $hits );
           action_add_header("X-Spam-$spamgraph ","SPAM hits=$hits ");
           action_add_header("X-Spam-Report","$SA_test_additions$report");
           }
        else {
            action_add_header("X-Spam-Status", "No");
        }

        }
    }
}

# DO NOT delete the next line, or Perl will complain.
1;




More information about the MIMEDefang mailing list