# please use the .m4 file, this file is not maintained!
LOCAL_CONFIG
F{LocalIP} /etc/mail/LocalIP
F{RelayTo} /etc/mail/relayto

LOCAL_RULESETS
Scheck_rcpt
# make sure you have TABs here, not BLANKs! sendmail will complain otherwise...
# first: get client addr
R$+			$: $(dequote "" $&{client_addr} $) $| $1
R0 $| $*		$@ ok			no client addr: directly invoked
R$={LocalIP}$* $| $*		$@ ok			from here
# not local, check rcpt
R$* $| $*		$: $>3 $2
# remove local part, maybe repeatedly
R$+			$:$>remove_local $1
# still something left?
R$*<@$+>$*		$#error $@ 5.7.1 $: 550 we do not relay

Sremove_local
# remove RelayTo part (maybe repeatedly)
R$*<@$*$={RelayTo}.>$*	$>3 $1 $4
R$*<@$=w.>$*		$: $>remove_local $>3 $1 $3
R$*<@$*>$*		$@ $1<@$2>$3
# dequote local part
R$-			$: $>3 $(dequote $1 $)
R$*<@$*>$*		$: $>remove_local $1<@$2>$3
