[Mimedefang] How to make MD do no more filtering in filter recipients/filter begin

David F. Skoll dfs at roaringpenguin.com
Wed Apr 11 09:00:00 EDT 2007


imacat wrote:

> Danny Kjaegaard <danny at resennet.dk> wrote:

>> How can i make MD accept an mail in filter_recipients/filter_begin and dont
>> run any further tests?

>     Maybe you can:

> ====
> sub filter_begin {
>     my($entity) = @_;
>     return if -e "$CWD/accept_this_mail";
>     if (<good condition>) {
>         `touch $CWD/accept_this_mail`;
>         return;
>     }
> }

There's no need to create a file.  If you want to do it from
filter_relay/filter_sender/filter_recipient, just do:

    return('ACCEPT_AND_NO_MORE_FILTERING', 'OK');

Once filter_begin has started, that trick no longer works.  Instead
use a global variable:

my $SkipFiltering;

sub filter_begin {
    $SkipFiltering = 0;

    if (some_condition()) {
        $SkipFiltering = 1;
    }
}

sub filter {
    return if $SkipFiltering;
    # Normal filtering here...
}

sub filter_end {
    return if $SkipFiltering;
    # Normal filtering here...
}

Regards,

David.



More information about the MIMEDefang mailing list