[Mimedefang] redirecting/dropping spoofed sender and null sender

Joe Arnstein mimedefang at claireandjoe.com
Fri Jul 23 16:08:00 EDT 2004


Hi All,

Could someone please help me with these custom anti-spoofing rules I'm
putting in?

I would like to drop all messages from <> not destined for
postmaster at mydomain and am not sure whether I should do it through
Sendmail or Mimedefang, or if the syntax below is correct.  

Also, because this is just an inbound mail gateway, most messages coming
from users at mydomain.com are going to be garbage (internal servers handle
all mail from users at mydomain), so we want to forward those messages to
maildrop at mydomain.com for inspection without losing the original
recipient info so that messages can be passed along if found to be
legit. 

Is sub filter_sender the best place for both of these items?  Here's
what I came up with using the mimedefang-filter man page (keeping in
mind my perl skills are lacking): 

##
sub filter_sender {
       my ($sender, $recipient, $ip, hostname, $helo) = @_;
       if ($sender =~ /^<\>$/) {
		if {$recipient =~ /^<?postmaster\@mydomain\.com>?$/i) {
		  return ('CONTINUE', "ok");
		}
        	return ('REJECT', 'We don\'t want your garbage.');
       }
	#  We also want to redirect messages with spoofed sender
@mydomain.com
	if ($sender =~ /(^|\@mydomain.com$/i) {  
	# Remove original recipients--We don't really want to remove the

 	# original headers, just tell sendmail to redirect
       foreach $recip (@Recipients) {
         delete_recipient($recip);    }
        # Send to spam address
       add_recipient('maildrop\@mydomain.com');
        }
}

Thanks for the help,
Joe





More information about the MIMEDefang mailing list