O'Reilly logo

Sendmail, 3rd Edition by Bryan Costales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 such as the following:

#!/bin/sh
/usr/sbin/sendmail -bt < $1 |\
         egrep "canonify.*input:|canonify.*returns|^>"

Here, the output is piped through egrep(1), which 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 names and addresses such as the following:

canonify,parse nobody@ourhost
canonify,parse nobody@ourhost.domain
canonify,parse nobody@distant.domain
 ...and so on

The output that is produced shows the input to the canonify rule set 3 and the result of each pass through that rule set:

> canonify           input: nobody @ ourhost
canonify         returns: nobody < @ ourhost . domain . >
> canonify           input: nobody @ ourhost . domain
canonify         returns: nobody < @ ourhost . domain . >
> canonify           input: nobody @ distant . domain
canonify         returns: 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). ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required