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


sendmail

sendmailSearch this book
Previous: 38.7 Add Debugging for Detail Chapter 38
Rule-Set Testing with -bt
Next: 38.9 Pitfalls
 

38.8 Batch Rule-Set Testing

The output that is produced by sendmail can become huge, especially when many addresses need testing. To simplify the process (and to help bulletproof your configuration file), consider using a shell script like the following:

#!/bin/sh
/usr/lib/sendmail -bt < $1 |\
        egrep " 3.*input:| 0.*returns|^>" |\
        sed   -e 's/^rewrite: ruleset  //'

Here, the output is piped through a egrep (1) selects only the lines of interest. If this script were to be called testcf.sh , it could be invoked with the following command line:

% 

testcf.sh address.list

Here, the address.list is a file consisting of pairs of rule-set numbers and addresses like the following:

3,0 nobody@ourhost
3,0 nobody@ourhost.domain
3,0 nobody@distant.domain

 ... and so on

The output that is produced shows the input to rule set 3 and the delivery agent returned by each call to rule set 0:

> 3,0 nobody@outhost
 3   input: nobody @ outhost
 0 returns: $# local $: nobody
> 3,0 nobody@ourhost.domain
 3   input: nobody @ ourhost . domain
 0 returns: $# local $: nobody
> 3,0 nobody@distant.domain
 3   input: nobody @ distant . domain
 0 returns: $# smtp $@ distant . domain $: nobody < @ distant . domain >

Note that the address.list file should contain every conceivable kind of address. The output from the shell script should be saved. At a later time, after the configuration file is changed, diff (1) can be used to see if the saved output differs from the new output (to see whether anything unexpected changed as a result of your modifications).

Also note that directly calling rule sets 3 and 0 produces less useful information than does the /parse rule-testing command (see Section 38.5.5 ). If you use that command, a diff (1) against prior output may provide more interesting and complete information.