$j
The fully qualified domain name of this host.
$w
The hostname component of the FQDN.
$m
The domain name component of the FQDN.
We can incorporate these macro definitions in our rewrite rules. Our Virtual Brewery configuration uses the $m macro.
The Lefthand Side
In the lefthand side of a rewriting rule, you specify a pattern that will match an address you wish to transform. Most characters are matched literally, but there are a number of characters that have special meaning; these are described in the following list. The rewrite rules for the lefthand side are:
$@
Match exactly zero tokens
$*
Match zero or more tokens
$+
Match one or more tokens
$-
Match exactly one token
$=
Match any phrase in class
$~
Match any word not in class
A token is a string of characters delimited by spaces. There is no way to include spaces in a token, nor is it necessary, as the expression patterns are flexible enough to work around this need. When a rule matches an address, the text matched by each of the patterns in the expression will be assigned to special variables that we'll use in the righthand side. The only exception to this is the $@, which matches no tokens and therefore will never generate text to be used on the righthand side.
The Righthand Side
When the lefthand side of a rewrite rule matches an address, the original text is deleted and replaced by the righthand side of the rule. All tokens in the righthand side are copied literally, unless they begin with a dollar sign. Just as for the lefthand side, a number of metasymbols may be used on the righthand side. These are described in the following list. The rewrite rules for the righthand side are:
$
This metasymbol is replaced with the
$[
This metasymbol resolves hostname to canonical name. It is replaced by the canonical form of the host name supplied.
$(
This is the more general form of lookup. The output is the result of looking up
$›
This will cause the rest of this line to be parsed and then given to ruleset
$#
This metasymbol causes ruleset evaluation to halt and specifies the mailer that should be used to transport this message in the next step of its delivery. This metasymbol should be called only from ruleset 0 or one of its subroutines. This is the final stage of address parsing and should be accompanied by the next two metasymbols.
$@
This metasymbol specifies the host that this message will be forwarded to. If the destination host is the local host, it may be omitted. The
$:
This metasymbol specifies the target user for the mail message.
A rewrite rule that matches is normally tried repeatedly until it fails to match, then parsing moves on to the next rule. This behavior can be changed by preceding the righthand side with one of two special righthand side metaymbols described in the following list. The rewrite rules for a righthand side loop control metasymbols are:
$@
This metasymbol causes the ruleset to return with the remainder of the righthand side as the value. No other rules in the ruleset are evaluated.
$:
This metasymbol causes this rule to terminate immediately, but the rest of the current ruleset is evaluated.
A Simple Rule Pattern Example
To better see how the macro substitution patterns operate, consider the following rule lefthand side:
$* ‹ $+ ›
This rule matches 'Zero or more tokens, followed by the ‹ character, followed by one or more tokens, followed by the › character.'
If this rule were applied to [email protected] or Head Brewer ‹ ›, the rule would not match. The first string would not match because it does not include a ‹ character, and the second would fail because $+ matches
If the rule were applied to Head Brewer ‹ [email protected] ›, the rule would match, and on the righthand side $1 would be substituted with Head Brewer and $2 would be substituted with [email protected].
If the rule were applied to ‹ [email protected] › the rule would match because $* matches