Access Classes in Rules
Class macros are useful only in the LHS of rules. The sendmail program offers two ways to use them:
$=prefix causes sendmail to seek a match between the workspace and one of the words in a class list.
$~prefix causes sendmail to accept only a single token in the workspace that does not match any of the words in a class list.
Matching Any in a Class: $=
The list of words that form a class are
searched by prefixing the class name with the characters
In this rule, the expression
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
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
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
Cw localhost mailhost server1 server2
$=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 ...