home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    


sendmailSearch this book
Previous: 10.2 Rule Set 3 Chapter 10
Rule Set 3
Next: 10.4 Nested Angle Brackets

10.3 Missing Addresses

The current, and only, rule in rule set 3 accepts anything or nothing (the $* ) between the angle brackets:

R$* < $* > $*       $2                      basic RFC822 parsing

But "nothing" can be a legal address. The expression <> 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 , that $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 address    

<- new

R$* < $* > $*       $2                      basic RFC822 parsing

Now run sendmail in rule-testing mode once again:


./sendmail -Cclient.cf -bt

ADDRESS 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 $n . Rule set 0 then arranges to forward the message to the hub for delivery to user MAILER-DAEMON .