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

Argument Function
-U Indicate initial user submission.
-Venvid Set the envelope ID to envid.
-Ndsn Set delivery status notification to dsn.
-Mxvalue Set macro x to value.
-Rreturn Set the part of the message returned with an error.
-Btype Set the MIME body type.
-pprotocol Set the receiving protocol and hostname.
-Xlogfile Log all traffic in the indicated log file.
-faddr Sender's machine address is addr.
-r addr Obsolete form of -f.
-h cnt Drop mail if forwarded cnt times.
-Fname Set the full name of this user to name.
-n Don't do aliasing or forwarding.
-Tvalue Set the QueueTimeout option to value.
-t Send to everyone listed in To:, Cc:, and Bcc:.
-bm Deliver mail (default).
-bD Run as a daemon in the foreground.
-ba Run in arpanet mode.
-bs Speak SMTP on input side.
-bd Run as a daemon.
-bH Clear the host status directory; equivalent to purgestat.
-bh Display the host status report; equivalent to hoststat.
-bt Run in test mode.
-bv Verify addresses; don't collect or deliver mail.
-bi Initialize the alias database.
-bp Print the mail queue.
-bz Create a parsed copy of the sendmail.cf file.
-q[time] Process queued mail. Repeat at interval time.
-Cfile Use file as the configuration file.
-c Set the HoldExpensive option to true.
-dlevel Set debugging level.
-e Set the ErrorMode option.
-Ooption=value Set option option to value.
-oxvalue Set an option using its old single-character name.
-I Alternate way to specify -bi.
-i Ignore dots in incoming messages.
-m Send to me, too.
-v Run in verbose mode.
-saddr 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 sendmail.cf 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 sendmail.cf 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 sendmail.cf 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 "sendmail ". These are:

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 "sendmail " in debugging examples. Other debugging arguments are:

The remaining arguments are rarely used on the command line:

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 sendmail.cf file. A basic sendmail.cf file can be built from m4 macros that come with the sendmail source code. "sendmail " provides examples of how this is done. The next section provides a complete list of the m4 macros that come with the sendmail distribution.