[Mimedefang] Ignoring Certain Domains

Michael Sims michaels at crye-leike.com
Wed May 21 00:15:01 EDT 2003


Quoting James McKiernan <James.McKiernan at robertwalters.com.au>:

> We now require to route mail leaving the company through this mail proxy. We
> do however not want this mail to be scanned by spamassassin.
> 
> Does anyone on the list know how to configure  spamassassin or mimedefang to
> ignore mail based on source IP or source domain or for that matter
> destination domain or email address.

Jim McCullars posted a message explaining how to do this in filter_relay(), but 
that method tells MIMEDefang to accept the message and stop any further 
processing.  I have a different approach, because I personally need my outgoing 
mail to still be scanned for viruses, I just do not want SpamAssassin to scan 
it.

I took an idea that James Ralston posted to the list last month regarding 
filtering (or not filtering) based on subnet/netmask pairs and expanded it a 
little bit to create a sub called relayIsTrusted():

sub relayIsTrusted($) {

  my ($address) = @_;
  
  # This hash defines a list of IPs and networks that are considered "trusted".
  # If a connected client has a source IP that matches one of these
  # entries, MIMEDefang will not perform any filtering on the message.
  # This is so outgoing messages aren't flagged as spam.  Each entry
  # should be a subnet/netmask pair.  To specifiy a single host, use
  # 255.255.255.255 as the netmask
  
  my %trustedSubnets = (
  
    '127.0.0.1'       => '255.255.255.255',
    '208.62.148.2'    => '255.255.255.255',
    ...
    
  );
  
  my $trustedRelay = 0;
  
  my $addr = inet_aton $address;
  while (my ($networkString, $netmaskString) = each %trustedSubnets) {
    my $network = inet_aton $networkString;
    my $netmask = inet_aton $netmaskString;
    if (($addr & $netmask) eq $network) { $trustedRelay = 1; last; }
  }
  
  return $trustedRelay;
  
}

IMPORTANT: You have to use the Socket module to get acess to "inet_aton".  Put 
this at the top of mimedefang-filter:

use Socket;

Now, I use this subroutine in filter_end, passing it $RelayAddr, to 
conditionally call the SA check, something like:

if (!relayIsTrusted($RelayAddr)) {

  my($hits, $req, $names, $report) = spam_assassin_check();
  ...

}

My actual filter is more complicated than that, but that should illustrate how 
it works.  HTH...

___________________________________________
Michael Sims
Project Analyst - Information Technology
Crye-Leike Realtors
Office: (901)758-5648  Pager: (901)769-3722
___________________________________________



More information about the MIMEDefang mailing list