[Mimedefang] mimedefang-filter, string matching from a (big) data source?

Fredrik Pettai pettai at nordu.net
Thu Feb 26 07:16:42 EST 2015


Hi,

I want to make a “semi” dynamic rule that would tag emails that matches a list of strings, something like this:

sub filter {
    my($entity, $fname, $ext, $type) = @_;

    return if message_rejected();

    if ($Sender =~ XYZ {

        if ($Subject =~ [input from a list] ) {
            action_change_header('Subject', “[ADD CUSTOM TAG]$Subject");
        } else {

            my $io;
            if ($io = $entity->open("r")) {
                while (defined($_ = $io->getline)) {
                    if ( [input from a list] ) {
                        action_change_header('Subject', “[ADD CUSTOM TAG]$Subject");
                        last;
                    }
                }
            $io->close;
            }
        }
    }

    return action_accept();
}


I wonder what the best solution would be to achieve this?

Currently, the [input from a list] is a text file which holds a lot of strings, one per line, and is currently about 6000+ lines long...
Is it a bad idea to open and read the text file from mimedefang-filter?
Would it be better to generate a new version of mimedefang-filter with the content of the text file inline?
Or should I consider something else?

The text file is also updated, but not that frequently… 

/P  




More information about the MIMEDefang mailing list