Although all mail, under the hub scheme, should be passed to the hub for processing, certain errors should still be handled locally. By recognizing these errors locally, the user is advised of mistakes immediately, rather than having to wait for mail to bounce.
When we discussed delivery agents, we showed you that
sendmail
requires the
local
delivery agent. Because
sendmail
requires it, you had to define it yourself (to keep
sendmail
from complaining):
Mlocal, P=/bin/mail, F=lsDFMAw5:/|@rmn, S=0, R=0, A=mail -d $u
Inside
sendmail
, a specially defined delivery agent exists. Called
error
, that delivery agent is one that you can't define yourself.
The
error
delivery agent is the internal mechanism that
sendmail
uses to process errors. When that delivery agent is selected, it causes
sendmail
to print the offending address, then the username part of the triple (the
$:
part) as an error message.
For example, recall the earlier experiment with three demo rules:
S0 R@ one R@$+ two R$+@$+ three
When this rule set was given an address of
@host
(note the missing user part), the RHS rewrote the workspace to be
two
. [3] We use a similar technique to select
sendmail
's built-in error handling delivery agent
error
.
[3] We are fudging here for the sake of a simple example. In reality a leading
@
is legal for route addresses (see theDontPruneRoutes
option in Section 34.8.20, DontPruneRoutes (R) , how route addresses are handled in rules in Section 29.4.3, "Handling Routing Addresses" , and theF=d
delivery agent flag in Section 30.8.16, F=d ).
Add the following new line to the client.cf file's rule set 0. Don't forget that the LHS, RHS, and comment must be separated from each other by tab characters, not spaces. But note that the RHS may contain space characters (not tabs) for clarity.
S0 # select delivery agentR@$+ $#error $: Missing user name
new R$+ $#hub $@${REMOTE} $:$1 forward to hub
Run sendmail again, this time to see which addresses are caught locally as errors and which are passed onward to the central hub.
%./sendmail -Cclient.cf -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> >0 @acme
rewrite: ruleset 0 input: @ acme rewrite: ruleset 0 returns: $# error $: Missing user name
Here, you are supplying an address that lacks a username. As expected, the
error
delivery agent is selected. If someone attempted to send mail to this address, they would get the error
@acme... Missing user name
Now feed sendmail a legal address:
>0 boss@acme
rewrite: ruleset 0 input: boss @ acme rewrite: ruleset 0 returns: $# hub $@ mailhost $: boss @ acme
This legal address, one with both a user and host part, bypasses the error-handling rule and will be accepted for delivery via the
hub
delivery agent.
Take some time to experiment. Give sendmail an assortment of addresses and try to predict which will produce errors and which will not.