Section E.2. The sendmail Command

The syntax of the sendmail command is deceptively simple:

sendmail [arguments] [address ...]

The syntax is deceptive because it hides the fact that there are a very large number of command-line arguments. Table E-2 lists all of them.

Table E-2. sendmail command-line arguments




Indicate initial user submission.


Set the envelope ID to envid.


Set delivery status notification to dsn.


Set macro x to value.


Set the part of the message returned with an error.


Set the MIME body type.


Set the receiving protocol and hostname.


Log all traffic in the indicated log file.


Sender's machine address is addr.

-r addr

Obsolete form of -f.

-h cnt

Drop mail if forwarded cnt times.


Set the full name of this user to name.


Don't do aliasing or forwarding.


Set the QueueTimeout option to value.


Send to everyone listed in To:, Cc:, and Bcc:.


Deliver mail (default).


Run as a daemon in the foreground.


Run in arpanet mode.


Speak SMTP on input side.


Run as a daemon.


Clear the host status directory; equivalent to purgestat.


Display the host status report; equivalent to hoststat.


Run in test mode.


Verify addresses; don't collect or deliver mail.


Initialize the alias database.


Print the mail queue.


Create a parsed copy of the file.


Process queued mail. Repeat at interval time.


Use file as the configuration file.


Set the HoldExpensive option to true.


Set debugging level.


Set the ErrorMode option.


Set option option to value.


Set an option using its old single-character name.


Alternate way to specify -bi.


Ignore dots in incoming messages.


Send to me, too.


Run in verbose mode.


Alternate form of -f.

Table E-2 lists over 30 command-line arguments. The table is a quick reference to all possible arguments, some of which are outdated in the latest version of sendmail. Perhaps the best-known argument that is now outdated is -bz. At one time it was used to preprocess the file. The idea was that storing the processed configuration would enhance speed. This outdated switch does not work in the newest versions of sendmail. If you used this argument with an older version of sendmail you might mistakenly believe it is still needed. Attempting to run it with the current sendmail release will just return an error.

Several arguments are redundant forms of other switches. For example, -c, -e, -I, -m, -r, -T, and -s are all deprecated switches that have been replaced by newer arguments. All of the arguments that set options, even those that are not deprecated, such as -i and -o, can be replaced with the -O switch. For example, the command line:

sendmail -m -s < mail.file

could be replaced by:

sendmail -OMeToo=true -OSaveFromLine=true < mail.file 

The -O argument provides the distinct advantage of being able to set any option. Arguments such as -m and -s set only one option each. The -O format is also easier to read and comprehend, particularly when the sendmail command is included inside a script.

Several of the command-line arguments from Table E-2 are covered in Chapter 10. These are:


Allows trusted users to override the sender address on outgoing messages. For security reasons, it is disabled on some systems. Obsolete alternative forms of this argument are -r and -s.


Reads the To:, Cc:, and Bcc: headers from standard input. Used to send a file that contains these headers or when typing in a test message, as in Chapter 10.


Runs sendmail in background mode, causing it to collect incoming mail. Use this argument on the sendmail command in the boot script.


Used to test sendmail address rewrite rules.


Initializes the aliases database. This is the same as the newaliases command covered in Chapter 10.


Sets the time interval at which the mail queue is processed. Use on the sendmail command in the boot script.


Loads an alternative sendmail configuration file. Use this to test the configuration before moving the new file to


Permits you to view the exchange of SMTP commands in real time.


Verifies address processing without actually sending mail.

Other than the two arguments (-bd and -q) used on the sendmail command line in the boot script to process incoming mail, the most common use for sendmail arguments is debugging. From the list above, -bt, -C, -bv, -v, and -t are all used in Chapter 10 in debugging examples. Other debugging arguments are:


Prints a list of mail that is queued for delivery. It is the same as the mailq command. Mail is queued when it cannot be delivered immediately because the remote host is temporarily unable to accept the mail. sendmail periodically processes the queue, based on the time interval you set with the -q argument, and attempts to deliver the mail in the queue. The queue can grow large enough to impede sendmail's performance if an important remote host is down. mailq shows how many items are queued as well as the source and destination of each piece of mail.

When the queue requires immediate processing, invoke sendmail using -q with no time interval. This processes the entire queue. Some variations of the -q argument allow you to selectively process the queue. Use -qIqueue-id to process only those queue entries with the specified queue identifier; -qRrecipient to process only items being sent to the specified recipient; or -qSsender to process only mail sent from the specified sender. The mailq command displays the queue identifier, sender address, and recipient address for every item in the queue.


Sets a sendmail option for this one instantiation of sendmail, e.g., -oA/tmp/test-aliases. Use this argument to test alternative option settings without editing the file. -o uses the old sendmail option syntax. An alternate form of the argument is -O, which uses the new option syntax, e.g., -OAilasFile=/tmp/test-aliases. See Section E.4.3 later in this appendix.


Sets the level of detail displayed when debugging sendmail code. Can be used to debug rewrite rules or to check configuration settings, e.g., sendmail -bt -d0.4. Most debug settings are useful only for sendmail source code debugging.


Sets the counter used to determine if mail is looping. By default, it is set to 30, which is a good operational value. When you are debugging a mail loop problem, set the hop count lower, e.g., -h10, to reduce the number of times a piece of mail is handled by the system. Otherwise, leave this value alone.


Displays the persistent host status, if sendmail is configured to maintain this status. The host status displays the name of each remote host that mail was sent to, the time the status of that host was last updated, and the result of the last attempt to deliver mail to that host. The directory of host status files can grow very large. Use -bH to clean out the host status directory.

The remaining arguments are rarely used on the command line:


Indicates the MIME message body type. Acceptable values are either 7BIT or 8BITMIME.


Requests that the sender be notified of the delivery status of the mail. The default value is FAILURE, DELAY, which notifies the sender when mail delivery fails or is delayed in the queue. Other acceptable values are NEVER, to request that no status notifications be returned to the sender, and SUCCESS, to request notification of successful mail delivery.


Sets a macro value for this instantiation of sendmail. For example, entering the command sets macro M to


Sets the sending protocol and the sending host. This is equivalent to setting the internal s and r macros. If a system has more than one external mail protocol, for example, UUCP and SMTP, this forces the system to use a specific protocol for this piece of mail.


Sets the amount of information returned to the sender when a message cannot be delivered. This can be either HDRS for headers-only, or FULL for the headers and the full message body.


Indicates that this mail comes directly from a user interface and was not forwarded from a remote mail handler.


Inserts an "envelope ID" into the outbound message that is returned if message delivery fails.


Logs all mail messages to the specified log file. This rapidly produces an enormous log file.


Disables the processing of aliases and mail forwarding.


Tells sendmail to deliver mail, which it will do anyway.


Reads the header From: line to find the sender. It uses three-digit reply codes, and ends error lines with <CRLF>. This is an obsolete argument.


Tells sendmail to use SMTP for incoming mail. When appropriate, sendmail will do this even without the -bs argument.


Normally, an SMTP message terminates when a line containing only a dot is encountered. This argument tells sendmail to ignore the dots in incoming messages.


Sends a copy of the mail to the person sending the mail. Normally this is done with a CC: or BCC: header in the message, not with the -m argument.


Runs sendmail as a foreground daemon so that it remains attached to the controlling terminal.


Sets the sender's full name.

This is a complete list of sendmail command-line arguments at this writing. Some of these arguments were recently introduced. Others are obsolete in the latest version of sendmail. Check the manpage for your system to find out exactly what arguments are available on your system.

When the sendmail command is executed, it reads its configuration from the file. A basic file can be built from m4 macros that come with the sendmail source code. Chapter 10 provides examples of how this is done. The next section provides a complete list of the m4 macros that come with the sendmail distribution.