8.6 Process-Specified Addresses

The sendmail rule-testing mode has always had the ability to test individual rule sets, but prior to V8.7 sendmail, rule sets could be specified only by number. Beginning with V8.7, rule sets can also be specified by name. Prior to V8 sendmail, rule set 3 was always called first, even if you did not specify it.[5]

[5] This was adopted from IDA sendmail.

8.6.1 Syntax

The > prompt expects rule sets and addresses to be specified like this:

> ident,ident,ident ...   address  

Each ident is a rule set name or number. When there is more than one rule set, they must be separated from each other by commas (with no spaces between them).

For numbered rule sets, the number must be in the range of 0 through the highest number allowed. A number that is too large causes sendmail to print the following two errors:

bad rule set number (maxmax) 
Undefined rule set number

A rule set whose number is below the maximum but that was never defined will act as though it was defined but lacks rules.

Named rule sets must exist in the symbol table. If the name specified was never defined, the following error is printed:

Undefined rule set ident

If any rule set number in the comma-separated list of rule sets is omitted (e.g., ident,,ident), sendmail interprets the second comma as part of the second identifier, thus producing this error:

Undefined rule set ,identifier

The address is everything following the first whitespace (space and tab characters) to the end of the line. If whitespace characters appear anywhere in the list of rule sets, the rule sets to the right of the whitespace are interpreted as part of the address.

We show named rule sets in our examples, even though numbered rule sets will work just as well. But by using named rule sets, the examples will still work even if the corresponding numbers change in the future.

8.6.2 The Address

Each address that is specified is handed almost as is to the rule set or sets being tested. Each is tokenized and placed into the workspace for rule set processing. To illustrate, observe the following rule-testing session:

ADDRESS TEST MODE (rule set 3 NOT automatically invoked)
Enter <rule set> <address>
> parse bill (Bill Bix)
parse              input: bill ( Bill Bix )
Parse0             input: bill ( Bill Bix )
Parse0           returns: bill ( Bill Bix )
ParseLocal         input: bill ( Bill Bix )
ParseLocal       returns: bill ( Bill Bix )
Parse1             input: bill ( Bill Bix )
Parse1           returns: $# local $: bill ( Bill Bix )
parse            returns: $# local $: bill ( Bill Bix )
> parse Bill Bix <bill >
parse              input: Bill Bix < bill >
Parse0             input: Bill Bix < bill >
Parse0           returns: Bill Bix < bill >
ParseLocal         input: Bill Bix < bill >
ParseLocal       returns: Bill Bix < bill >
Parse1             input: Bill Bix < bill >
Parse1           returns: $# local $: Bill Bix < bill >
parse            returns: $# local $: Bill Bix < bill >
> canonify,parse Bill Bix <bill >
canonify           input: Bill Bix < bill >
Canonify2          input: bill
Canonify2        returns: bill
canonify         returns: bill
parse              input: bill
Parse0             input: bill
Parse0           returns: bill
ParseLocal         input: bill
ParseLocal       returns: bill
Parse1             input: bill
Parse1           returns: $# local $: bill
parse            returns: $# local $: bill
>

The first test illustrates that sendmail does not strip RFC822-style comments from addresses before tokenizing them.

The second test illustrates that sendmail does not internally recognize addresses in angle brackets. Instead, the canonify rule set throws away everything but the address in angle brackets, as shown in the third test.

Note that in many actual configuration files, the canonify rule set 3 also focuses on the host part of the address. For this reason, you should always begin with the canonify rule set 3 unless you are tuning a particular rule for which you know the precise input required.

8.6.3 Rule Set 3 Always Called First with -bt

When sendmail starts to run in rule-testing mode, its appearance and initial behavior vary from vendor to vendor and from version to version. When rule-testing mode begins, sendmail always prints an introductory banner. Pre-V8 sendmail printed the following banner:

ADDRESS TEST MODE
Enter <rule set> <address>
>

It is important to note that (unless a banner says otherwise) sendmail always calls rule set 3 first.[6] That is, even if you try to test rule set 0, you always first see the effects of rule set 3.

[6] We use a rule set number here because the versions of sendmail that always started with rule set 3 are too old to use named rule sets.

Beginning with V8 sendmail, rule set 3 is no longer automatically called. To ensure that there is no confusion, V8 sendmail prints this banner:

ADDRESS TEST MODE (rule set 3 NOT automatically invoked)
Enter <rule set> <address>
>

Note that in all versions the last line (the >) is a prompt. At this prompt, you can specify a rule set and an address or, beginning with V8.7, any of the commands shown in Section 8.1.

8.6.4 The Output

Each line of output produced during rule testing begins with an indication of the rule set number or name being processed:

canonify           input: Bill Bix < bill >

The word input precedes each address that is about to be processed by a rule set:

canonify           input: Bill Bix < bill  >

The word returns precedes each address that is the result of rewriting by a rule set:

canonify         returns: bill

When rule sets call other rule sets as subroutines, those calls are shown in the output with input and returns pairs. In the following, the Canonify2 rule set is called as a subroutine rule set from inside the canonify rule set 3:

canonify           input: Bill Bix < bill >
Canonify2          input: bill
Canonify2        returns: bill
canonify         returns: bill

The output can also contain rule set operators:

parse            returns: $# local  $:  bill

In this output, the operators are printed as they would appear in the configuration file. The $# selects a delivery agent, and the $: specifies the user. Under old versions of sendmail those operators are printed in the output as control characters:

rewrite: rule set  0 returns: ^V local  ^X  bill

The correspondence between control characters in the old-style output and sendmail configuration file operators is given in Table 8-2.

Table 8-2. Control characters versus operators

Control

Operator

Meaning

^V

$#

Select delivery agent

^W

$@

Specify host for delivery agent

^X

$:

Specify user for delivery agent



    Part I: Build and Install
    Part II: Administration
    Part III: The Configuration File