Matching Any in a Class: $=
The list of words that form a class are searched by
prefixing the class name with the characters
$=
:
R$=X $@<$1>
In this rule, the expression $=X
causes
sendmail to search a class
for the word that is in the current workspace. If
sendmail finds that the word
has been defined, and if it finds that the word is
associated with the class $=X
, only then is a match made.
The matching word is made available for use in the RHS
rewriting. Because the value of $=X
is not known ahead
of time, the matched word can be referenced in the
RHS with the $
digit
positional operator.
Consider the following example. Two classes have been
declared elsewhere in the configuration file. The
first, $=w
,
contains all the possible names for the local
host:
Cw localhost mailhost server1 server2
The second, $=D
,
contains the domain names of the two different
networks on which this host sits:
CD internal.domain external.domain
If the object of a rule is to match any variation on the local hostname at either of the domains and to rewrite the result as the official hostname at the appropriate domain, the following rule can be used:
R $=w . $=D $@ $w . $2 make any variations "official"
If the workspace contains the tokenized address
server1.external.domain,
sendmail first checks to see
whether the word server1 has
been defined as part of the class w
. If it has, the dots
in the rule and workspace match each other, and then
sendmail looks up
external.domain.
If both the host part and the domain part ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.