The job of rule set 0 is to select a delivery agent for each recipient.
It is called once for each recipient and must rewrite each into a
special form called a
. A triple is simply three pieces
of information: the symbolic name of the delivery agent,
the host part of the address, and the user part of the address.
Each part is indicated in the RHS by a special prefix operator, as shown in
The triple is formed by rewriting with the RHS. It looks like this:
The delivery agent selection must be the first of the three. In addition to
specifying the delivery agent,
also causes rule set 0
to exit. The other two parts of the triple must appear in the order
All three parts of the triple must be present in the RHS. The only
exception is the
part when the delivery
agent has the
be present for IDA and V8
but must be absent for all other versions of
Not all rules in rule set 0 are specifically used to select a delivery
agent. It may be necessary, for example, to canonicalize an address
Section 28.6.6, "Canonicalize Hostname: $[ and $]"
before being able to decide whether the address is local or remote.
If an address passes through rule set 0 without selecting
a delivery agent, the following error message is produced, and the
mail message bounces:
buildaddr: no mailer in parsed address
Therefore it is important to design a rule set 0 that selects a delivery
agent for every legitimate address.
If a triple is missing the user part, the following error is
buildaddr: no user
If the delivery agent that is selected is one for which there is no
configuration file declaration, the error is
buildaddr: unknown mailer
bad delivery agent name here
The user part of the triple is intended for use in the command line
of the delivery agent and in the RCPT command in an SMTP connection.
For either use, that address is rewritten by rule set 2, the
equate of the delivery agent, and rule set 4,
as illustrated in
This means that the user part can be in focused
form, because the focus is later removed by rule set 4.
But the user part
be a single username (no host)
The rewritten result is stored for use when
a delivery agent's
Section 30.4.1, A=
) argument is expanded.
For example, for the
delivery agent, the rewritten result is the
username as it will be given to
for local delivery.
The rewritten result is also given to a remote site during
the exchange of mail using the SMTP protocol. The local machine
tells the remote machine the name of the recipient by saying
followed by the rewritten user portion
of the triple.
When it selects a delivery agent, rule set 0 also selects
the rules that will be used in rewriting sender
and recipient addresses. A sender address is rewritten by
the rule set specified by the
Section 30.4.11, S=
The recipient addresses are rewritten by
the rule set specified by the
specifies rule set 0 or
if either is undeclared, then that portion of rewriting
We won't cover individual
rule sets here, because
they depend on the individual needs of delivery agents.
Instead, we recommend that you examine how your configuration file uses
them. You'll probably be surprised to find that many
equates reference nonexistent rules (which means that
will do no rewriting).
Typically, some early rules in rule set 0 are intended to
detect addresses that should be delivered locally. A rule
that accomplishes that end might look like this:
R$+ <@ $w> $#local $:$1 local address
macro is the name of the local host. Note that the
RHS strips the focused host part from the username.
At some sites, the local host can be known by any of several
names. A rule to handle such hosts would begin with a class
declaration that adds those names to the class
the first line below):
Cw font-server fax printer3
R$+ <@ $=w> $#local $:$1 local address
is special because it is the one to which
automatically appends the alternative name of the
local host. The class declaration line above adds names that
might not automatically detect. Usually, such a declaration
would be near the top of the configuration file, rather than
in rule set 0, but technically it can appear anywhere in the file.
This rule looks to see whether
an address contains any of the names in class
. If it does, the
in the LHS matches, and the RHS selects the
On central mail server machines, rule set 0 may also have
to match from a list of hosts for which the central server is an
MX recipient machine (see
Section 19.6.26, FEATURE(use-cw-file)
After handling mail destined for the local host, rule set 0
generally looks for addresses that require a knowledgeable
host to forward messages on the local host's behalf.
In the following rule,
Section 31.10.5, $B
) is the name
of a machine that knows how to deliver BITNET mail (see
Section 19.4.5, "Relays"
R$* <@ $+.BITNET> $* $#smtp $@$B $:$1<@$2.BITNET>$3 user@host.BITNET
would have been added by users
when sending mail. Note that
in the LHS is case-insensitive;
a user can specify
, and this rule will still match.
A similar scheme can be used for other specialty addresses,
such as UUCP and DECnet.
Hosts sometimes deliver mail to a few UUCP connections locally and forward
to other UUCP connections through a knowledgeable host.
The rules that handle this
situation often make use of another class:
R$* <@ $=V.UUCP> $#uucp $@$2 $:$1 user@localuucp
R$* <@ $+.UUCP> $#smtp $@$Y $:$1<@$2.UUCP> kick upstairs
Here, the class
contains a list of local UUCP connections.
They are matched by the first rule, which selects the
delivery agent. All other UUCP addresses are passed to the
knowledgeable host in
Section 31.10.45, $Y
)). The user part (
that is given to the knowledgeable host is the original address as it
appeared to the LHS.
Next, rule set 0 typically sees whether it can send the mail message
over the network. In the following example we assume that the local host
is connected to an IP network:
# deal with other remote names
R$* <@ $*> $* $#smtp $@$2 $:$1<@$2>$3 email@example.com
Remember that we have already screened out and handled
delivery to the local host, and therefore the focused host
of the LHS) is on the network.
delivery agent is selected (to deliver using the SMTP protocol),
with connection to be made to
in the LHS).
The focus is kept in the user portion of the RHS triple. Remember
that the user portion will be rewritten by rule sets 2,
and 4. Also remember that rule set 4 will defocus the address.
The reason we keep the focus here is because rule set 2 and
rules expect the host part of addresses to be focused.
Whatever is left after all preceding rules in rule set
0 have selected delivery agents is probably a local address.
Here, we check for a username without a host part:
R$+ $#local $:$1 regular local names
Notice that the user part is not focused; it is unfocused because
there is no host part on lone local usernames.