start page | rating of books | rating of authors | reviews | copyrights

sendmail

sendmailSearch this book
Previous: 36.3 List of Recipient Addresses Chapter 36
The Command Line
Next: 36.5 sendmail's exit() Status
 

36.4 Processing the Command Line

The sendmail program's ability to perform different tasks necessitates that the command line be processed in steps.

First

The command line is prescanned to set its -d debugging switch. That switch allows you to watch all the steps taken by sendmail prior to processing the rest of the command-line switches.

Second

Internal macros are given values, then the command line's argv[0] (the name used to run sendmail ) is processed. That name can determine the sendmail program's mode of operation.

Third

The command-line switches are processed. Although the configuration file is read after the command line is processed, options in the command line (with -o and -O ) still supersede those in the configuration file.

Fourth

The configuration file is read.

Fifth

If sendmail is running in a mode that allows it to verify or deliver to recipients, the remainder of the command line is processed to extract the recipient list.

36.4.1 First: Prescanning the Command Line

When sendmail begins to run, it performs a preliminary scan of its command-line arguments. It does this because some actions need to be performed before its configuration file is read. The -d command-line switch is processed during the pre-scanning phase.

36.4.2 Second: Processing Prior to the Switches

After the command-line switches are prescanned, but before they are processed in full, sendmail performs two important internal tasks.

36.4.2.1 Initialize the environment

The environmental variables that are given to sendmail when it is first run are ignored. When running delivery agents, sendmail provides a small, customized environment. See Section 22.2, "The Environment" for a detailed discussion of this step.

36.4.2.2 Initialize macros

Certain macros are next declared and assigned values. The $w macro (see Section 31.10.40, $w ), $j macro (see Section 31.10.38, $v ), and the $=w class macro (see Section 32.5.8, $=w ) are given values that identify the current host. The $m macro (see Section 31.10.24, $m ) is given a value that is the local domain name. The $k macro (see Section 31.10.21, $k ) and the $=k class (see Section 32.5.2, $=k ) are also given values at this time. The $v macro (see Section 31.10.38 ) is assigned a value that is the current version of the sendmail program. The $b macro (see Section 31.10.3, $b ) is given the current date and time as its value.

36.4.3 Third: Process Switches

Command-line switches are processed by sendmail as they appear in the command line, from left to right. The processing of switches ends when an argument is found that lacks a leading - character or when a -- argument is found.

36.4.4 Fourth: Read the Configuration File

The fact that the configuration file is read after the command-line switches are processed can lead to some confusion. Some, but not all, command-line switches can overwrite some configuration file commands. Since there is no general rule, we describe the behavior of each item (such as macros and options) in a chapter dedicated to each.

36.4.5 Fifth: Collect Recipients

The final step sendmail undertakes in processing its command line is gathering the list of recipients. Each recipient (or list of recipients if more than one is contained in a single command-line argument) is fully processed for delivery, and any error messages are printed before delivery is actually undertaken.

If sendmail is running in a mode that doesn't require recipients, any list of recipients in the command line is silently ignored.


Previous: 36.3 List of Recipient Addresses sendmail Next: 36.5 sendmail's exit() Status
36.3 List of Recipient Addresses Book Index 36.5 sendmail's exit() Status