[Mimedefang] Multiple Spamdrop Question

Matthew.van.Eerde at hbinc.com Matthew.van.Eerde at hbinc.com
Tue Oct 5 16:36:24 EDT 2004


Andrew Embury wrote:
> What I would like to do
> is have a spamdrop at domain address for each distinct domain I
> am hosting.  Does anyone have a recipe or other wisdom to share in
> making this happen? 

Hmmm... what would you do if a single piece of spam was addressed to recipients in multiple domains?  Forward to both?

Maybe something like this in mimedefang-filter (untested)

# spamdrop is hash; key = domain, value = address
sub load_spamdrops();
my %spamdrops = load_spamdrops();


filter_end()
{	...
	# inside "well, we know it's spam" block...
	my %recipient_domains = ();
	for my $recip (@Recipients)
	{	delete_recipient($recip); # original recipient should not get it
		$recip =~ /\@(.*?)>?$/; # extract domain
		my $domain = $1 or next; # skip weird emails
		$recipient_domains{$domain}++;
	}
	# at this point %recipient_domains has keys for all recipient domains
	my %spamdrop_addresses = ();
	for my $domain (keys %recipient_domains)
	{	if ($spamdrops{$domain})
		{	my $address = $spamdrops{$domain};
			$spamdrop_addresses{$address}++;
		}
	}
	# at this point %spamdrop_addresses has keys for all spamdrops
	for my $address (keys %spamdrop_addresses)
	{	add_recipient($address);
	}
	...
}

sub load_spamdrops()
{	# statically hardcode
	# or pull from LDAP
	# or whatever

	return
	(	"first.example.com" => "admin1 at first.example.com",
		"second.example.com" => "admin2 at first.example.com",
		...
	);
}



More information about the MIMEDefang mailing list