Sendmail Installation and Operation Guide
SMM:08-39
is applied to the input:
UCBARPA:eric
the rule will match, and the values passed to the RHS will be:
$1 UCBARPA
$2 eric
Additionally, the LHS can include $@ to match zero tokens. This is not bound to a $n on
the RHS, and is normally only used when it stands alone in order to match the null input.
5.1.2. The right hand side
When the left hand side of a rewriting rule matches, the input is deleted and replaced by
the right hand side. Tokens are copied directly from the RHS unless they begin with a dollar
sign. Metasymbols are:
$n
Substitute indefinite token n from LHS
$[name$]
Canonicalize name
$(map key $@arguments $:default $)
Generalized keyed mapping function
$>n
"Call" ruleset n
$#mailer
Resolve to mailer
$@host
Specify host
$:user
Specify user
The $n syntax substitutes the corresponding value from a $+, $-, $*, $=, or $~ match on
the LHS. It may be used anywhere.
A host name enclosed between $[ and $] is looked up in the host database(s) and replaced
by the canonical name
14
. For example, "$[ftp$]" might become "ftp.CS.Berkeley.EDU" and
"$[[128.32.130.2]$]" would become "vangogh.CS.Berkeley.EDU." Sendmail recognizes its
numeric IP address without calling the name server and replaces it with its canonical name.
The $( ... $) syntax is a more general form of lookup; it uses a named map instead of an
implicit map. If no lookup is found, the indicated default is inserted; if no default is specified
and no lookup matches, the value is left unchanged. The arguments are passed to the map for
possible use.
The $>n syntax causes the remainder of the line to be substituted as usual and then passed
as the argument to ruleset n. The final value of ruleset n then becomes the substitution for this
rule. The $> syntax expands everything after the ruleset name to the end of the replacement
string and then passes that as the initial input to the ruleset. Recursive calls are allowed. For
example,
$>0 $>3 $1
expands $1, passes that to ruleset 3, and then passes the result of ruleset 3 to ruleset 0.
The $# syntax should only be used in ruleset zero, a subroutine of ruleset zero, or rulesets
that return decisions (e.g., check_rcpt). It causes evaluation of the ruleset to terminate immedi-
ately, and signals to sendmail that the address has completely resolved. The complete syntax for
ruleset 0 is:
$#mailer $@host $:user
This specifies the {mailer, host, user} 3-tuple necessary to direct the mailer. If the mailer is
14
This is actually completely equivalent to $(host hostname$). In particular, a $: default can be used.