18.1 Why Rules?

Rules in a sendmail.cf file are used to rewrite (modify) mail addresses, to detect errors in addressing, and to select mail delivery agents. Addresses need to be rewritten because they can be specified in many ways, yet are required to be in particular forms by delivery agents. To illustrate, consider Figure 18-1, and the address:

Figure 18-1. Rules modify addresses, detect errors, and select delivery agents

If the machine uuhost were connected to yours over a dial-up line, mail might be sent by UUCP, which requires addresses to be expressed in UUCP form:


Rules can be used to change any address, such as friend@uuhost, into another address, such as uuhost!friend for use by UUCP.

Rules can also detect and reject errors on the machine from which mail originated. This prevents errors from propagating over the network. Mail to an address without a username is one such error:


It is better to detect this kind of error as early as possible instead of having the host neighbor reject it.

Rules can also select delivery agents. Delivery agents are the means used by sendmail to actually transmit or deliver mail messages. Rules examine the address of each envelope recipient and select the appropriate delivery agent. For example:


Here, rules detect that here.us.edu is the name of the local machine and then select the local delivery agent to perform final delivery to the user root's system mailbox.

And lastly, rules can be used to make decisions about such things as rejecting spam, or deferring to a different queue.

    Part I: Build and Install
    Part II: Administration
    Part III: The Configuration File
    Chapter 21. The D (Define a Macro) Configuration Command
    Chapter 24. The O (Options) Configuration Command