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 triple. 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 Table 29.2.
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
[email protected] first, then
All three parts of the triple must be present in the RHS. The only
exception is the
host part when the delivery
agent has the
F=l flag set.
It may be present for IDA and V8 sendmail
but must be absent for all other versions of sendmail.
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
$] (see Section 28.6.6, "Canonicalize Hostname: $[ and $]")
before being able to decide whether the address is local or remote.
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 produced:
buildaddr: no user
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
R= 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 must be a single username (no host)
local delivery agent.
The rewritten result is stored for use when
a delivery agent's
A= (see Section 30.4.1, A=) argument is expanded.
For example, for the
local delivery agent, the rewritten result is the
username as it will be given to /bin/mail 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
S= equate (see Section 30.4.11, S=).
The recipient addresses are rewritten by
the rule set specified by the
R= equate (see Section 30.4.10).
S= specifies rule set 0 or
if either is undeclared, then that portion of rewriting
We won't cover individual
S= 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
S= equates reference nonexistent rules (which means that
sendmail will do no rewriting).
R$+ <@ $w> $#local $:$1 local address
$w macro is the name of the local host. Note that the
RHS strips the focused host part from the username.
Cw font-server fax printer3 R$+ <@ $=w> $#local $:$1 local address
w is special because it is the one to which
sendmail automatically appends the alternative name of the
local host. The class declaration line above adds names that sendmail
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
w. If it does, the
$=w in the LHS matches, and the RHS selects the
local delivery agent.
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,
$B (see 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 [email protected]$B $:$1<@$2.BITNET>$3 [email protected]
.BITNET would have been added by users
when sending mail. Note that
BITNET in the LHS is case-insensitive;
a user can specify
BiTNeT, 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 [email protected]$2 $:$1 [email protected] R$* <@ $+.UUCP> $#smtp [email protected]$Y $:$1<@$2.UUCP> kick upstairs
Here, the class
$=V 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
$Y (see 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.
# deal with other remote names R$* <@ $*> $* $#smtp [email protected]$2 $:$1<@$2>$3 [email protected]
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
R= 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