[Mimedefang] Bypassing outgoing mail - filter_relay blocking all incomming mail

Rick Knight rick at rlknight.com
Sat Feb 22 22:35:01 EST 2003


David F. Skoll wrote:

>	man mimedefang-filter
>
>and search for:
>
>	send_quarantine_notifications()
>
>  
>
David,

I've read the man page and I've gone through the archives and I think 
I've got stuff in the right place, but I still don't get the quarantine 
notifications. Below is the last part of my mimedefang-filter. Can you 
tell me what I've missed?

Rick Knight
(rick at rlknight.com)

sub filter_relay ($$$) {
    my ($ip, $name, $helo) = @_;
    return('ACCEPT_AND_NO_MORE_FILTERING', "ok") if $ip eq "64.165.88.2";
    return('CONTINUE', 'OK');
}

# If SpamAssassin found SPAM, append report.  We do it as a separate
# attachment of type text/plain

sub filter_end_aux ($) {
    my($entity) = @_;

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

    # Spam checks if SpamAssassin is installed
    if ($Features{"SpamAssassin"}) {
        if (-s "./INPUTMSG" < 200*1024) {
            # Only scan messages smaller than 200kB.  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 we're sure it is spam, quarantine and bounce
        if ($hits > 10) {
        md_log('spam -bounced-', $hits, $RelayAddr);
        my($score);
        action_add_header("X-Spam-Score", "Hits=$hits required=$req");
        action_add_header("X-Spam-Status", "Message quarantined");
        action_quarantine_entire_message();
        action_bounce("Message seems to be Spam, rejected!");
        }

        # If it is not spam, add header and say so
        if ($hits < $req) {
        md_log('not spam', $hits);
        my($score);
        action_add_header("X-Spam-Score", "Hits=$hits required=$req");
        action_add_header("X-Spam-Status", "No");
        }
       
            # If it looks like spam but doesn't qualify above,
        # score it, add report and headers
        if ($hits >= $req) {
                md_log('spam', $hits, $RelayAddr);
                my($score);
                if ($hits < 40) {
                    $score = "*" x int($hits);
                } else {
                    $score = "*" x 40;
                }
            # We add a header which looks like this:
                # X-Spam-Score: 6.8 (******) NAME_OF_TEST,NAME_OF_TEST
                # The number of asterisks in parens is the integer part
                # of the spam score clamped to a maximum of 40.
                # MUA filters can easily be written to trigger on a
                # minimum number of asterisks...
                #action_change_header("X-Spam-Score", "$hits ($score) 
$names");
                action_add_header("X-Spam-Warning", "SpamAssassin says 
this message is SPAM");
                action_add_header("X-Spam-Status", "Yes, hits=$hits 
required=$req");
                action_add_header("X-Spam-Report","$report");

                # If you find the SA report useful, add it, I guess... 
                action_add_part($entity, "text/plain", "-suggest",
                                "$report\n",
                                "SpamAssassinReport.txt", "inline");
        }       

       
        } else {
            }
           
                # Now this is the real filter_end
                sub filter_end ($) {
                my($entity) = @_;
               
                # Do the real work
                filter_end_aux($entity);

                # And send notifications
                send_quarantine_notifications();
                }

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






More information about the MIMEDefang mailing list