[Mimedefang] Per domain filtering

Alain DESEINE alain at cabinfo.com
Sun Nov 16 11:27:52 EST 2003


Many thanks to all !

Here is what i do if this can help :

#***********************************************************************
# %PROCEDURE: scan_mimedefang_domains ($)
# %ARGUMENTS:
#  domain name of the mail address
# %RETURNS:
#  Nothing
# %DESCRIPTION:
#  Open the mimedefang-domain configuration file to get the
#  configuration of the domain
#***********************************************************************
sub scan_mimedefang_domains ($)
{
my($domain) = @_;

$avirus = 'n';
$aspam  = 'n';
# On ouvre le fichier
open(DOMAINES, "< /etc/mail/mimedefang-domains") or die "Can't find 
/etc/mail/mimedefang-domains !\n";
while (<DOMAINES>)
{
         ($fdomain, $fantivirus, $fantispam) = split /:/, $_;

         next if ( substr($_, 0, 1) eq "#" );

         if ($fdomain eq $domain)
         {
                 $avirus = $fantivirus;
                 $aspam  = substr($fantispam,0,1);
                 break;
         }
}
}
#***********************************************************************
# %PROCEDURE: filter_begin
# %ARGUMENTS:
#  None
# %RETURNS:
#  Nothing
# %DESCRIPTION:
#  Called just before e-mail parts are processed
#***********************************************************************
sub filter_begin () {
     # On separe les eventuels destinataires multiples par domaines.

     if (stream_by_domain())
     {
         return;
     }

     # On recherche la paramétrage du domaine, s'il existe
     scan_mimedefang_domains ($Domain);

     if ( $avirus eq "o" )
     {
        ... Check for viruses !
     }
  ... and so on !
}

#*********************************************************************************

I do the same test for spam in filter_end function !

Just need a file named mimedefang-domains in /etc/mail that lokk like 
something like that !

foo1.com:o:o
foo2.com:o:o
foo3.com:o:n
...

I plan to had an email for spam redirection in the conf file.

Hope this help !

Regards,

Alain Deseine.


At 13:23 14/11/2003 -0500, you wrote:
>No, he's right about this.  The filter_begin, filter, and filter_end are
>run in the same slave.  Filter_relay, filter_sender, and
>filter_recipient do not necessarily run in the same slave.
>
>As far as the per domain filtering, it's been working well for me.
>Here's an excerpt of what's in filter_begin:
>
>#***********************************************************************
>     if (stream_by_domain()) {
>         return;
>     }
>
>     if (lc($Domain) eq "xxxxxx.com") {
>         $TriggerSpamBounce = 15;
>         $TriggerSpamTrap = 5;
>         $SpamTrap = 'spamtrap at xxxxxx.com';
>         $TriggerSpam = 3;
>     } elsif (lc($Domain) eq "yyyyyy.com") {
>         $TriggerSpamBounce = 20;
>         $TriggerSpamTrap = 6;
>         $SpamTrap = 'spamtrap at yyyyyy.com';
>         $TriggerSpam = 3;
>     } else {
>         $TriggerSpamBounce = 0;
>         $TriggerSpamTrap = 0;
>         $SpamTrap = $AdminAddress;
>         $TriggerSpam = 0;
>     }
>#***********************************************************************
>
>I do AV on every message, so these values are tuned for usage with SA.
>Just replace the $Trigger.... variables with a simple boolean for scan
>or not.  Then in filter or filter_end, use conditional logic to call the
>AV & SA.
>
>Charles




More information about the MIMEDefang mailing list