Fwd: [Mimedefang] Ignore local mail / outgoing mail

Mitch Mitch at 0Bits.COM
Tue Sep 16 11:05:01 EDT 2003


This has been answered umpteen times, but here goes again:

I use the following (attached) in my filter_relay() routine in /etc/mail/mimedefang-filter.
Change the obvious bits for your network/relay hosts.

HOWEVER, remember to start the mimedefang process in your startup scripts
with the '-r' flag or the filter_relay will be ignored. See

	man mimedefang

for more info.

Cheers
Mitch

-------- Original Message --------
Subject: [Mimedefang] Ignore local mail / outgoing mail
Date: Tue, 16 Sep 2003 07:54:11 -0700
From: Mike Heller <mike at dsny.com>
Reply-To: mimedefang at lists.roaringpenguin.com
Organization: Destiny Media Technologies Inc.
To: mimedefang at lists.roaringpenguin.com

Can anyone tell me how I would set up MIMEDefang to ignore local mail
(withing our office) and outgoing mail?  Our support guys send out
software installers (exe files) from time to time and they are getting
stripped.  Zipping is not really an option as many of the end users
don't have a clue what to do with a zip file.  I have MIMEDefang running
and it does strip "bad"attachments, but I just want to ignore outgoing
mail scan and possible local traffic as well.

Thanks for the input,
Mike
-------------- next part --------------
use Socket;
sub filter_relay ($$$) {

	my ($hostip, $hostname, $helo) = @_;

#        md_syslog('debug', "RELAY: <$hostip> <$hostname> <$helo>");
	my $addr = '';
	my $network_string = '';
	my $mask_string = '';

	# List networks that should be exempt from all filtering by
	# putting their network/mask pairs into the exempt_subnets
	# associative array.  (Follow the example for the loopback.)

	my %exempt_subnets = (
	'127.0.0.0',		'255.0.0.0',	# loopback
	'192.168.254.0',	'255.255.255.0'	# my internal net
	);

	# Relays
	@trusted = ("relay.org", "another-relay.com");
	for $host (@trusted) {
		return ('ACCEPT_AND_NO_MORE_FILTERING', 'ok') 
						if ($host =~ /$helo/i);
	}

	# If the address of the connecting client falls within one of
	# the subnets defined by %exempt_subnets, then bypass all
	# further filtering.

	$addr = inet_aton $hostip;
	while (($network_string, $mask_string) = each %exempt_subnets) {
		my $network = inet_aton $network_string;
		my $mask = inet_aton $mask_string;
		if (($addr & $mask) eq $network) {
			return ('ACCEPT_AND_NO_MORE_FILTERING', 'ok');
		}
	}

	# The client isn't in an exempt subnet; filtering should
	# continue.
	return ('CONTINUE', 'ok');
}


More information about the MIMEDefang mailing list