R$* < $* > $* $2 basic RFC822 parsing
But "nothing" can be a legal address.
<> is a legal sender address that
is used when sending bounced mail to prevent further bouncing.
To catch such addresses, a new rule needs to be written preceding the first.
That new rule looks like this:
R$* <> $* $n handle <> error address
Here, the LHS matches any address that has nothing between the angle brackets. Observe how this new LHS catches such an address:
workspace LHS $* match zero or more < < match exactly > > match exactly $* match zero or more
When such an empty address is matched by the LHS of the new rule,
the workspace is rewritten by the RHS of that rule to contain
only the single macro
$n. Recall from
Chapter 7, Macros,
$n was defined to be the name of the user
from whom all bounced mail is sent:
define(n as MAILER-DAEMON)
To observe the effect of this new rule in action, add it to the client.cf file. This new rule should precede the existing rule in rule set 3:
S3 # preprocessing for all rule sets
R$* <> $* $n handle <> error addressnew R$* < $* > $* $2 basic RFC822 parsing
Now run sendmail in rule-testing mode once again:
./sendmail -Cclient.cf -btADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> >
3,0 Your Fullname <you@here>rewrite: ruleset 3 input: Your Fullname < you @ here > rewrite: ruleset 3 returns: you @ here rewrite: ruleset 0 input: you @ here rewrite: ruleset 0 returns: $# hub $@ mailhost $: you @ here
Here, two rule sets (3 and 0) are specified instead of one as you have been
doing all along.
Rule set 3 is called first, and it throws away everything but the address between
the angle brackets. The rewritten workspace is then given to rule set
0, which selects the
hub delivery agent. This is as it should
be, with a good address being forwarded to the mail hub.
Note that there must be no space on either side of the comma.
But now give sendmail an empty address, with nothing in the angle brackets:
3,0 <>rewrite: ruleset 3 input: < > rewrite: ruleset 3 returns: MAILER-DAEMON rewrite: ruleset 0 input: MAILER-DAEMON rewrite: ruleset 0 returns: $# hub $@ mailhost $: MAILER-DAEMON
As you may expect, the empty address is
caught by the new rule in rule set 3 and converted
(in the workspace) to the value of
Rule set 0 then arranges to forward the message to the hub
for delivery to user