Mail Administration Guide

Right-Hand Side of Address Rewriting Rules

When the left-hand side of a rewriting rule matches, the input is replaced by the right-hand side. Tokens are copied directly from the right-hand side, unless they begin with a dollar sign, in which case they are treated as macros and expanded.

Table 3-12 shows the metasymbols for more complicated substitutions.

Table 3-12 sendmail Right-Hand Side Metasymbols

Symbol 

Description 

$x

Expands macro x

$n

Substitutes indefinite token n from LHS; n is a digit

$>n

Calls rule set n; n is a digit

$#mailer

Resolves to mailer

$@host

Specifies host

$:user

Specifies user

$[host$]

Maps to primary host name 

${x name$}

Maps name through NIS map or NIS+ table $x; if the map name begins with rev, sendmail will reverse the aliases.

The $n (n being a digit) syntax substitutes the corresponding value from a $+, $-, $*, or $~x match on the LHS. It may be used anywhere.

The $>n syntax substitutes the remainder of the line as usual and then passes it to rule set n. The final value of rule set n then becomes the substitution for this rule (like a procedure or function call).

Only use the $# syntax in rule set 0. Evaluation of the rule set stops immediately, and signals are sent to sendmail that the name has completely resolved. The complete syntax is:


$#mailer$@host$:user

This specifies the {mailer, host, user} triple necessary to direct the mailer. More processing may then take place, depending on the mailer. For example, local names are aliased.

A right-hand side may also be preceded by a $@ or a $: to control evaluation. A $@ prefix returns the remainder of the right-hand side as the value. A $: prefix terminates the rule immediately, but the rule set continues. Thus it can be used to limit a rule to one application. Neither prefix affects the result of the right-hand side expansion.

The $@ and $: prefixes can precede a $> spec. For example:


R$+	$:$>7$1

matches anything, passes that to rule set 7, and continues; the $: is necessary to avoid an infinite loop. The $[host]$ syntax replaces the host name with the "official" or primary host name, the one listed first in the hosts.byname NIS map, or /etc/hosts if not running NIS. It is used to eliminate nicknames for hosts. The ${x name $} syntax replaces the string by the result of the nis_map_name indicated in macro $x.

The rule below can be added to ruleset 0 to forward mail to the mail host from a system (like a router) that might not be able to route mail itself:


R$*<@$*.$m>		$#ether $@mailhost $:$1<@$2.$m>