[Mimedefang] RE: Using relay_check()

Troy Carpenter troy at carpenter.cx
Thu Jul 18 14:21:08 EDT 2002


Well, since nobody has given the examples for relay_check...here's mine.

Actually, I use filter_recipient since it has more things I can check in
conjunction with the blacklists.  I am toying with the idea of rejecting
only if multiple blacklists hit, but so far this has worked without any
false rejects (except on multi-hop, which is commented out).  I probably
need to add some dialup check as well.

In short, I always accept mail sent to postmaster and perform the checks
on all other messages.  I don't process much mail on my server (just for
my family, maybe on average 50 messages per day including the
rejects/spam/etc/system emails), and these reject rules hit about 5-10
times per day.

Hope this helps.

Troy Carpenter
troy at carpenter.cx


#***********************************************************************
# %PROCEDURE: filter_recipient
# %ARGUMENTS:
#  $recipient, $sender, $ip, $hostname
# %RETURNS:
#  (0, rejection string) for rejected emails
#  (1, "ok") for accepted emails
# %DESCRIPTION:
#  Called before everyting. This routine Cannot modify mail.
#***********************************************************************
sub filter_recipient {
    my ($recipient, $sender, $ip, $hostname) = @_;
    $skipchecks=0;

    # Always accept email to postmaster without checks
    if ($recipient =~ /^<?postmaster\@carpenter.cx>?$/i) {
	$skipchecks=1;
	return (1, "ok");
    }

    # Check a few online databases
    if (relay_is_blacklisted($ip, "relays.ordb.org")) {
	return (0, "Relay $hostname refused by blackhole site
relays.ordb.org. Please see http://www.ordb.org/faq/#why_rejected");
    }
    if (relay_is_blacklisted($ip, "list.dsbl.org")) {
	return (0, "Relay $hostname refused by blackhole site
list.dsbl.org.  Please see http://dsbl.org");
    }
#    if (relay_is_blacklisted($ip, "multihop.dsbl.org")) {
#	return (0, "Relay $hostname refused by blackhole site
multihop.dsbl.org. Please see http://dsbl.org");
#    }
    if (relay_is_blacklisted($ip, "relays.osirusoft.com") ) {
	return (0, "Relay $hostname refused by blackhole site
relays.osirusoft.com.  No further information");
    }
    return (1, "ok");
}





More information about the MIMEDefang mailing list