[Mimedefang] Ignoring Certain Domains

James McKiernan James.McKiernan at robertwalters.com.au
Wed May 21 00:39:01 EDT 2003


Thanks David,

I'll have a look at your code when I get a chance, also on another topic is
it a bad idea to edit mimedefang.pl? I have been doing so and now wonder if
I could have just added all the functionality I needed to mimedefang-filter?

Thanks,

James.



James McKiernan
Systems Support
Robert Walters
Tel: + 61 (0)2 8224 9201
Fax: + 61 (0)2 9223 8166
E-mail: james.mckiernan at robertwalters.com.au
Web: http://www.robertwalters.com 

-----Original Message-----
From: Michael Sims [mailto:michaels at crye-leike.com] 
Sent: Wednesday, 21 May 2003 14:14
To: mimedefang at lists.roaringpenguin.com
Subject: Re: [Mimedefang] Ignoring Certain Domains

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
___________________________________________
_______________________________________________
MIMEDefang mailing list
MIMEDefang at lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

**********************************************************************
CAUTION: Electronic mail sent through the Internet is not secure and could
be intercepted by a third party. 

This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they   
are addressed. If you have received this email in error please notify 
your systems administrator.

This footnote also confirms that this email message has been swept by 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp
**********************************************************************

**********************************************************************
CAUTION: Electronic mail sent through the Internet is not secure and could
be intercepted by a third party. 

This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they   
are addressed. If you have received this email in error please notify 
your systems administrator.

This footnote also confirms that this email message has been swept by 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp
**********************************************************************



More information about the MIMEDefang mailing list