Using a Map for RelayTo in check_rcpt

Last Update 1999-11-24
The check_rcpt ruleset can optionally use a class
F{RelayTo} /etc/mail/RelayTo
to list all hosts you relay mail to or accept mail for, which is used in the ruleset removelocal that is called in check_rcpt :
Scheck_rcpt
...
R$+			$:$>removelocal $1
...
Some people asked for a solution using a map instead of a class (having the usual advantages: no restart of the sendmail daemon necessary etc). Here is a solution (an old version has been posted to comp.mail.sendmail ): Introduce a map like this:
Kisrt dbm -a@RELAYTO /etc/mail/isrt
with entries in the form
allowed.domain  RELAYTO
(the RHS does not matter in this version.) Next, put this ruleset in your .cf:
Sremovelocal
R$*<@$+.>$*		$:$1<@$(isrt $2 $:$2.$)>$3
R$*<@$*@RELAYTO>$*		$>removelocal $>3 $1 $3
#R$*<@$=w.>$*		$:$>removelocal $>3 $1 $3
R$*<@$-.$+.>$*		$>removelocal $1<@$3.>$4
R$*<@$*>$*		$@ $1<@$2>$3
# dequote local part
R$-			$: $>3 $(dequote $1 $)
R$*<@$*>$*		$: $>removelocal $1<@$2>$3

This version does not take entries in class w into account, you have to add them to the map, or you have to enable the rule

R$*<@$=w.>$*		$:$>removelocal $>3 $1 $3
removelocal checks not just for exact match on domains, but also for subdomains. For example, if you have
subdomain.to    RELAYTO
in your map, and someone wants to mail to
<user@host.subdomain.to>
the ruleset should allow this.
[(links)] [Hints] [Avoiding UBE] [cf/README] [New]
Copyright © Claus Aßmann Please send comments to: <ca at sendmail.org>
Disclaimer: the information provided may be inaccurate or outdated or incomplete. Please contact me if you find an error.