Chapter 6. The sendmail Command Line

The initial behavior of sendmail is determined largely by the command line used to invoke it. The command line can, for example, cause sendmail to use a different configuration file or to rebuild the aliases file rather than deliver mail. The command line can be typed at your keyboard, executed from a boot-time script, or even executed by an MUA when sending mail.

The format of the sendmail command line is:

argv[0] switches recipients

Here, argv[0] is the name used to run sendmail. The switches, if any are present, must always precede the list of recipients. The recipients is a list of zero or more recipient address expressions.

Alternative argv[0] Names

The sendmail program can exist in any of several places, depending on the version of the operating system you are running. Usually, it is located in the /usr/sbin directory and is called sendmail,[103] but it can alternatively be located in the /etc, /usr/lib, /usr/libexec, or /usr/etc directory. The location of the sendmail program can be found by examining the /etc/rc files for BSD Unix or the /etc/init.d files for Sys V Unix (Role As a Daemon on page 17). On some BSD-derived systems, the mailwrapper program and its /etc/mail/mailer.conf file define where sendmail is located.

In addition to the name sendmail, other names (in other directories) can exist that alter the behavior of sendmail. Those alternative names are usually symbolic links to /usr/sbin/sendmail. On some systems they can be hard links, and in rare cases you might actually find them to be copies. The complete list of other names is shown in Table 6-1.

Table 6-1. Alternative names for sendmail

Name

§

Mode of operation

hoststat

hoststat (V8.8 and Later) on page 221

Print persistent host status (V8.8 and later)

mailq

mailq on page 222

Print the queue contents

newaliases

newaliases on page 223

Rebuild the aliases file

purgestat

purgestat (V8.8 or Later) on page 223

Purge persistent host status (V8.8 and later)

smtpd

smtpd on page 223

Run in daemon mode

When sendmail looks for the name under which it is running, it strips any leading directory components from argv[0] and compares the result (in a case-sensitive fashion) to its internal list of alternative names. If a match is found, its mode of operation is changed to conform to that of the alternative name. If no match is found (if, say, a link is named Mailq, note the uppercase M), sendmail does not change its mode.

The name that is found is used to build an argument list for use with process listings. For example, if the name was sendmail.mx (from SunOS), a process listing produced with ps(1) would look something like this:

root  1247  620 p0 S  07:22 0:00 -AA15186 (sendmail.mx)

Here, the (sendmail.mx) shows that sendmail was run under the name sendmail.mx.

Prior to V8.10, the hardcoded name "sendmail" was used for logging purposes with syslog(3) (syslog(3) on page 514). Therefore, logged errors and warnings always appeared to come from sendmail, regardless of the name used to run it.

Beginning with V8.10, sendmail recognizes the -L command-line switch (-L on page 243) to set the name that will be logged with syslog(3). Note, however, that the default name is still "sendmail.”

Finally, be aware that command-line switches are processed immediately after the name but before sendmail finalizes its mode of operation. Thus, the use of particular switches can completely cancel any special meaning given to a name.

hoststat (V8.8 and Later)

The hoststat command is a synonym for the -bh command-line switch. It causes sendmail to print its persistent host status and exit. Persistent host status is enabled with the HostStatusDirectory option (HostStatusDirectory on page 1037).

The output produced by this command begins with a heading such as this:

-------------- Hostname --------------- How long ago ---------Results---------

Then, for each host whose status it has saved, sendmail prints this information:

Hostname

This is the name of the host that was connected to. It might not be the hostname specified for the recipient. It could easily be an MX record instead. If a message has multiple recipients, a separate status line will be produced for each unique host that is tried. If this name is prefixed with an asterisk, the status file is locked and currently being updated.

How long ago

This shows how long ago this status record was updated. It is printed in the form:

DD+HH:MM:SS

Here, DD is the number of days. If the status were updated less than one day ago, the DD+ is omitted. The HH is hours, the MM is minutes, and the SS is seconds. The colons are literal.

Results

This shows the result of the last connection attempt, failure, or success. If no reason was stored, this prints as:

No status available

If a result was stored, it will print in two parts:

smtp msg

The smtp is the SMTP reply code. The msg is the text of the message generated by the other end or other program.

To illustrate, consider this output:

-------------- Hostname --------------- How long ago ---------Results---------
there.ufoa.edu                              00:00:51 250 f21IuJf8029510 Message acce
*books.oreilly.com                          07:43:39 250 f21KGlGS029512 Message acce
progr.rammers.com                           06:55:08 No status available
fbi.dc.gov                                  03:28:53 Connection refused

Here, the previous connections to there.ufoa.edu and books.oreilly.com were successful. The status for books.ora.com is currently being updated, hence the asterisk showing it is locked. The host prog.rammers.com shows no status because connection to it could not be made. The last example shows that the connection to fbi.dc.gov was refused by that host.

Note that the results are limited to 27 characters unless the -v command-line switch (-v on page 249) is also used. In that case, results are limited to 79 characters, thus providing more complete information.

mailq

The name mailq (a synonym for the -bp command-line switch) causes sendmail to print the contents of its mail queues and then exit (Printing the Queue on page 422).

Note that the location of the queues is set with the QueueDirectory option (QueueDirectory on page 1070). That location can be overridden from the command line, but if it is, sendmail might give up its special privileges (unless it was run by root).

newaliases

The name newaliases (a synonym for the -bi command-line switch) causes sendmail to rebuild all the aliases database files, print summary information, and then immediately exit (Rebuild the Alias Database on page 478). In this mode the -v command-line switch (-v on page 249) is automatically implied, and sendmail runs in verbose mode.

The location of the aliases file is given in the configuration file with the AliasFile option (Alphabetized Options on page 970). That location can be overridden from the command line, but if it is, sendmail gives up its special privileges (unless it was run by root).

purgestat (V8.8 or Later)

The name purgestat is a synonym for the V8.8 and later -bH command-line switch (-bH on page 234). It causes sendmail to clear (purge) all the host-status information that was being saved under the HostStatusDirectory option’s directory (HostStatusDirectory on page 1037). Clearing is done by removing all the directories under the HostStatusDirectory directory. Note that the HostStatusDirectory directory is not itself removed.

Beginning with V8.10, sendmail purges host-status information only for hosts that exceed the setting of the Timeout.hoststatus option (Timeout.hoststatus (V8.8 and later) on page 1103).

smtpd

The name smtpd is a synonym for the -bd command-line switch (-bd on page 234). It causes sendmail to run in the background as a daemon, listening for incoming SMTP mail (Daemon mode (-bd) on page 20). This mode of operation is usually combined with the -q command-line switch (Periodically with -q on page 427) which causes sendmail to periodically process the queue.

Command-Line Switches

Command-line switches are command-line arguments that begin with a - character, and precede the list of recipients (if any). The forms for command-line switches, where X is a single letter, are:

-XBoolean switch
-Xargswitch with argument

All switches are single letters. The complete list is shown in Table 6-2.

Table 6-2. Command-line switches

Switch

§

Version

Description

-A

-A on page 231

V8.12 and later

Specify sendmail.cf versus submit.cf.

-B

-B on page 232

V8.1 and later

Specify message body type.

-b

-b on page 233

All versions

Set operating mode.

-ba

-ba on page 233

Not V8.1- V8.6

Use ARPAnet/Grey Book protocols.

-bD

-bD on page 233

V8.8 and later

Run as a daemon, but don’t fork.

-bd

-bd on page 234

All versions

Run as a daemon.

-bH

-bH on page 234

V8.8 and later

Purge persistent host status.

-bh

-bh on page 235

V8.8 and later

Print persistent host status.

-bi

Rebuild the Alias Database on page 478

All versions

Initialize alias database.

-bm

-bm on page 235

All versions

Be a mail sender (the default).

-bP

-bP on page 236

V8.12 and later

Print number of messages in the queue.

-bp

Printing the Queue on page 422

All versions

Print the queue.

-bs

-bs on page 236

All versions

Run SMTP on standard input.

-bt

Chapter 8 on page 299

All versions

Rule-testing mode.

-bv

-bv on page 237

All versions

Verify: don’t collect or deliver.

-bz

-bz on page 238

Not V8

Freeze the configuration file.

-C

-C on page 238

All versions

Location of the configuration file.

-c

HoldExpensive on page 1036

(deprecated)

Set HoldExpensive option to true.

-D

-D on page 239

V8.13 and later

Redirect debugging output into a file.

-d

Chapter 15 on page 530

All versions

Enter debugging mode.

-E

-E on page 240

Sony NEWS only

Japanese font conversion.

-e

ErrorMode on page 1028

(deprecated)

Set the ErrorMode option’s mode.

-F

-F on page 240

All versions

Set the sender’s full name.

-f

-f on page 241

All versions

Set the sender’s address.

-G

-G on page 242

V8.10 and later

Set the gateway submission mode.

-h

-h on page 242

(deprecated)

Initial hop count.

-I

-I on page 243

(deprecated)

Synonym for -bi.

-i

-i on page 243

(deprecated)

Set the IgnoreDots option to true.

-J

-J on page 243

Sony NEWS only

Japanese font conversion.

-L

-L on page 243

V8.10 and later

Syslog label.

-M

Command-Line Definitions on page 786

V8.7 and later

Define a sendmail macro on the command line.

-m

MeToo on page 1051

Deprecated

Set the MeToo option to true.

-N

-N on page 244

V8.8 and later

Specify DSN NOTIFY information.

-n

Prevent Aliasing with -n on page 482

All versions

Don’t do aliasing.

-O

Command-Line Options on page 948

V8.7 and later

Set a multicharacter option.

-o

Command-Line Options on page 948

All versions

Set a single-character option.

-p

-p on page 246

V8.1 and later

Set protocol and host.

-Q

The -Q command-line switch on page 440

V8.13 and later

Quarantine an envelope.

-q

Periodically with -q on page 427

All versions

Process the queue.

-R

-R on page 247

V8.8 and later

What DSN info to return on a bounce.

-r

-f on page 241

(deprecated)

Synonym for -f.

-s

SaveFromLine on page 1085

(deprecated)

Set the SaveFromLine option to true.

-T

QueueTimeout on page 1075

(deprecated)

Set the QueueTimeout option.

-t

-t on page 248

All versions

Get recipients from message header.

-U

-U on page 248

V8.8 through V8.11

This is the initial MUA-to-MTA submission.

-V

-V on page 249

V8.8 and later

Specify the ENVID string.

-v

-v on page 249

All versions

Run in verbose mode.

-X

Log Transactions with -X on page 512

V8.1 and later

Log transactions.

-x

-x on page 250

OSF and AIX 3.x only

Ignored.

Some switches are called Boolean because they are either true or false. The -v switch, for example, is Boolean because it puts sendmail into verbose mode if it is present (true). If it is absent (false), sendmail does not run in verbose mode.

Some switches take arguments. The -C switch, for example, tells sendmail where to find its configuration file. When a switch takes an argument, the argument can immediately follow the letter or be separated from it with whitespace:[104]

-Ctest.cf         ← good
-C test.cf         ← also good

The only exceptions to this rule are the -d command-line switch (set debugging mode) and the -q command-line switch (enter queue mode). They cannot have whitespace between the letter and the arg.

Some switches, such as -q (process the queue), can either be Boolean or take an argument:

-q                 ← Boolean
-q1h               ← with argument

The position of switches in the command line is critical. If any follow the list of recipients, they are wrongly taken as mail addresses and lead to bounced mail. But the order in which switches appear prior to the recipients is not important. That is, they can appear in any order without changing the behavior of sendmail.

An undefined switch letter causes the following error to be printed and sendmail to immediately exit:

sendmail: illegal option -- bad letter here

The special switch -- can be used to delimit the switches from the list of recipients:

% /usr/sbin/sendmail -- -jim

Here, the recipient is -jim. To prevent the - of -jim from being wrongly interpreted as indicating a switch, the special switch -- is used to mark the end of all switches.[105]

List of Recipient Addresses

All command-line arguments that follow the switches (if any) are taken to be the addresses of recipients. The addresses in the list can be separated by spaces, by commas, or by both:

addr1 addr2 addr3
addr1,addr2,addr3
addr1, addr2, addr3

Certain modes specified by the -b command-line switch, such as -bp (for print the queue’s contents), cause sendmail to ignore any list of recipients.

Be sure to escape any characters in addresses that have special meaning to your shell. For example, because the ! character has special meaning to the C shell,[106] it should be escaped by preceding it with a backslash character:

host\!user

If sendmail expects a list of recipients and finds none, it prints the following message and exits:

Recipient names must be specified

Note that under some circumstances, sendmail might try to collect the message before issuing this error.

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 sendmail macros are given their starting values, and 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.

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 the configuration file is read. The -d command-line switch is processed during the prescanning phase.

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.

Initialize the environment

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

Initialize sendmail macros

Certain sendmail macros are next declared and assigned values. The $w macro ($w on page 850), $j macro ($j on page 830), and $=w class macro ($=w on page 876) are given values that identify the current host. The $m macro ($m on page 833) is given a value that is the local domain name. The $k macro ($k on page 831) and the $=k class ($=k on page 872) are also given values at this time. The $v macro ($v on page 849) is assigned a value that is the current version of the sendmail program. The $b macro ($b on page 807) is given the current date and time as its value.

Third: Processing 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, beginning with V8, when a -- argument is found.

Fourth: Reading 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. Because there is no general rule, we describe the behavior of each item (such as macros and options) in a chapter dedicated to each.

Fifth: Collecting 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.

sendmail’s exit( ) Status

Like any other program under Unix, sendmail can return meaningful values to the environment and thus to you. All the possible exit values are documented in <sysexits.h>, along with the values assigned to each name. Here, we provide a bit more explanation about the most commonly used names.

The relationship between each exit value and its corresponding Delivery Status Notification (DSN) detail is shown in Table 20-4 on page 721. That table also summarizes the values described here.

EX_CANTCREAT

Can’t write a user’s file sendmail exit value

An exit value of EX_CANTCREAT (the value 73) means that an output file could not be written to. This error generally refers to a user-specified file rather than a system- or configuration-file-specified file. For example, an attempt to write to a file that has any execute bit set in its permissions can yield an error, as can writing to a file that has more than one link. Writing to a file that is not a regular file can cause an error if the SafeFileEnvironment option (SafeFileEnvironment on page 1084) is set. Note that for some problems that produce this error, sendmail won’t print an error message.

EX_CONFIG

A configuration error sendmail exit value

The EX_CONFIG exit value (the value 78) means that a fatal configuration problem was found, but not necessarily while reading the configuration file. Failure of a delivery agent to function correctly can lead to this kind of failure.

Note that the EX_CONFIG error and EX_SOFTWARE error (discussed later) cause the local postmaster to get a copy of the message on the presumption that local errors can only be fixed locally.

EX_IOERR

A system I/O error occurred sendmail exit value

An exit value of EX_IOERR (the value 74) means that a serious operating system error occurred. This class of error relates mostly to disk I/O.

EX_OK

No problems, all was fine sendmail exit value

The EX_OK exit code (value 0) indicates that sendmail did its job and there were no errors.

Note that this should be the exit value of all the programs that sendmail runs when they succeed without errors. The following C-language code, for example, returns a random value:

main(  )
{
         ← need a" return 0 "or exit(0) here
}

EX_OSERR

A system resource error sendmail exit value

The EX_OSERR exit code (value 71) results from various operating system errors. In general, this exit value is accompanied by an error message describing the problem.

EX_OSFILE

A critical system file failure sendmail exit value

The EX_OSFILE exit code (value 72) results when certain system files could not be opened and when certain system programs could not be executed.

EX_SOFTWARE

An internal software error sendmail exit value

The EX_SOFTWARE exit code (value 70) indicates that a software error occurred. For example, when figuring out whether to speak SMTP, sendmail looks to see whether the $u sendmail macro is present in the A= equate for the selected delivery agent (The special case of $u in A= on page 740). If $u is absent, sendmail will speak SMTP. If sendmail was compiled without SMTP support (SMTP on page 144), the fork(2)'d child prints an error and exits with an EX_SOFTWARE exit code.

Note that the EX_CONFIG (discussed earlier) and EX_SOFTWARE errors cause the local postmaster to get a copy of the message on the presumption that local errors can only be fixed locally.

EX_TEMPFAIL

A recoverable error sendmail exit value

The EX_TEMPFAIL exit code (value 75) is returned by sendmail to indicate that a temporary error has occurred. Temporary errors mean that the mail message will be put in (or remain in) the queue for the present and another delivery attempt will be made later.

One example of this type of error occurs when looking up aliases via a network service, such as NIS. If all the servers are too busy to answer before a timeout, sendmail should temporarily queue the message and look up the aliases again later.

EX_UNAVAILABLE

A resource is unavailable sendmail exit value

The EX_UNAVAILABLE error code (value 69) indicates that some system resource is unavailable—for example, if the body size of an incoming message is larger than the size limit imposed by the M= equate (M= on page 746).

Also, all delivery agent programs must be designed to return an exit value that is defined in <sysexits.h>. If a poorly designed delivery agent exits with some other value, sendmail will issue this error and consider the delivery to have failed.

EX_USAGE

A command was used incorrectly sendmail exit value

The EX_USAGE error code (value 64) means that a command or configuration line was used incorrectly.

Pitfalls

  • Prior to V8 sendmail, if the list of recipients contained an address that began with any of the prescanned switches, sendmail would wrongly view that recipient as a switch during its prescan phase. For example, mail to joe, bill, -Cool caused sendmail to try to use a file named ool as its configuration file.

  • Command-line switches must precede recipient addresses. Switches that are mixed in with recipient names are treated as recipient addresses.

  • Old versions of sendmail (including IDA and some versions of BSD) would syslog(3) a warning if the old frozen configuration file didn’t exist. The V8 and SunOS versions of sendmail no longer check for a frozen configuration file, so nothing is ever logged about this.

  • Prior to V8 sendmail, unknown command-line switches were silently ignored. Therefore, sending mail from a shell script could fail for reasons that were difficult to find. For example, specifying the preliminary hop count wrongly with -j, instead of correctly with -h, caused your presetting of the hop count to be silently ignored.

  • Some old BSD and SunOS versions of sendmail set the default sender’s full name from the environment variable NAME even when running as a daemon or when processing the queue. This can lead to the superuser’s full name occasionally showing up wrongly as a sender’s full name. IDA and V8 sendmail clear the full name in -bd and -q modes but use different methods. To prevent this problem under other versions of sendmail, the env(1) program can be used to clean up the environment passed to sendmail:

    # env - /usr/sbin/sendmail -bd -q1h
  • V8 sendmail uses getopt(3) to parse its command-line arguments so that a switch and its argument can have whitespace between them without harm:

    -C configfile

    But, for bizarre historical reasons, the -d and -q switches differ from all other command-line switches. There can never be space between the -d and its arguments, nor between the -q and its arguments:

    -d 4
    -q 4

    If there is space between them, the argument (here, 4) is taken to be a recipient name. This is true for all versions of sendmail.

Alphabetized Command-Line Switches

Command-line switches are those command-line arguments that precede the list of recipients and begin with a - character. For a complete list of command-line switches, see Table 6-2 on page 223.

In this section, we present a full description of each switch in alphabetical order. Where two switches differ by case, the uppercase switch precedes the lowercase switch.

-A

Specify sendmail.cf versus submit.cf V8.12 and later

There are four ways that email messages can be submitted to sendmail by other programs. One way is with the -t command-line switch (-t on page 248). This causes sendmail to read the message on its standard input, and to parse the addresses from the header lines. Another way is with the -bs command-line switch (-bs on page 236), which causes sendmail to speak SMTP on its standard input and output. The third way is to specify recipients on the command line, and to feed sendmail the message on its standard input. The fourth way is to connect directly to sendmail’s MSA port (FEATURE(no_default_msa) on page 635).

For the -t and -bs forms of submission to behave like messages submitted via the MSA port, it is desirable to use a special configuration file. This -A command-line switch does just that. By following it with a c character, you tell sendmail to use a configuration file named submit.cf in place of the default configuration file. If the -A switch is followed by an m character, the default configuration file is used:

% /usr/sbin/sendmail -Acuse submit.cf
% /usr/sbin/sendmail -Amuse sendmail.cf

If the -A switch is omitted, the choice of configuration file depends on the mode under which sendmail was run. That is, if it was run with a -t or a -bs, the behavior is that of -Ac. Otherwise, the behavior is that of -Am.

Note that this -A command-line switch can be used by ordinary users without causing sendmail to drop any special privileges.

The submit.cf file is installed automatically when you install sendmail.cf (The submit.cf File on page 66). A custom one can easily be created using the FEATURE(msp) (FEATURE(msp) on page 633).

-B

Specify message body type V8.1 and later

MIME support in V8 sendmail has been coupled to ESMTP and the BODY parameter for the MAIL command. The BODY parameter is passed through as is to the delivery agent. Two special parameters are internally recognized by sendmail. They tell sendmail that the message body is either 7bit or 8bitmime. 7bit forces the high bit off. 8bitmime causes sendmail to leave the high bit unchanged. Both override any setting of the SevenBitInput option (SevenBitInput on page 1090).

When sendmail accepts a connection with another site for incoming mail, it has no way to determine from context whether it is dealing with MIME mail. To override any configured assumptions, you can use the -B command-line switch:

-B 7BIT
-B 8BITMIME

Case is unimportant (7BIT and 7bit both work). The 7bit causes the local sendmail to tell the remote sendmail (in ESMTP mode) that the message body should have the high bit stripped from every byte. Conversely, 8bitmime tells the remote sendmail to preserve the high bit of each byte.

The value given to this -B command line or received via the BODY parameter is stored in the ${bodytype} sendmail macro (${bodytype} on page 808).

-b

Set operating mode All versions

The -b switch tells sendmail in what mode to operate. For example, sendmail can “become” a daemon listening for incoming SMTP connections, or it can run in a mode that tells it to simply print the contents of the queue and exit. The form of the -b switch is:

-bmode

If mode is more than a single letter, all but the first letter is silently ignored. If the mode is missing or not one of those allowed, sendmail prints the following error message and exits:

Invalid operation mode bad letter here

If the -b command-line switch is omitted altogether, the default mode becomes -bm (deliver mail and exit).

Beginning with V8.7 sendmail, the letter that selected the operating mode is assigned at startup to the ${opMode} sendmail macro (${opMode} on page 839).

-ba

Use ARPAnet/Grey Book protocols Not V8.1 through V8.6

In the distant past, mail messages on ARPAnet were sent by using the ftp(1) protocol. Because that protocol was never intended for use with email, many different departures were designed (“patched in”) to solve particular problems. That growing anarchy caused Jonathan B. Postel to design SMTP in 1982 and to document that protocol in RFC821 (updated to RFC2821). Since then, SMTP has replaced FTP as the Internet standard for email.

In the belief that sufficient time had passed for all sites to have adopted SMTP, the -ba mode was deemed obsolete and removed from V8.1 sendmail. It turned out that the British Grey Book protocol was based on FTP. To support that protocol, this -ba command-line switch was restored in V8.7 sendmail.

The -ba switch causes each line of a message to be terminated with a carriage-return line-feed pair instead of with a newline. This switch also forces sendmail to guess the sender from the message header, instead of parsing it from the envelope. The -ba switch should never be used outside of a Grey Book setting.

Prior to V8.14, this -ba switch would cause STARTTLS to fail. Beginning with V8.14, this switch now works correctly with STARTTLS.

-bD

Run as a daemon, but don’t fork V8.8 and later

The -bD command-line switch is almost exactly the same as the -bd switch. That is, it causes sendmail to run as a daemon, but unlike the -bd switch, it prevents sendmail from performing a fork(2) and thereby keeps sendmail in the foreground. The -bD switch also prevents detaching from the controlling terminal (as does the -d99.100 debugging switch, -d99.100 on page 574).

This -bD command-line switch allows sendmail to be run from a “wrapper” script—for example, to detect whether it died or was killed:

#!/bin/sh
SENDMAIL=/usr/sbin/sendmail
UCBMAIL=/usr/ucb/mail

if [ -f $SENDMAIL -a -f $UCBMAIL ]
then
        $SENDMAIL -bD -q1h
        echo ${SENDMAIL}, which should run forever, died \
                | $UCBMAIL -s "Sendmail died" root
fi

Note that the echo line will never be reached as long as sendmail continues to run. Also note that you will not be able to restart sendmail in the usual manner with a SIGHUP if you use this script.

-bd

Run as a daemon All versions

The -bd command-line switch causes sendmail to become a daemon, running in the background, listening for and handling incoming SMTP connections.[107]

To become a daemon, sendmail first performs a fork(2). The parent then exits, and the child becomes the daemon by disconnecting itself from its controlling terminal. The -bD command-line switch can be used to prevent the fork(2) and the detachment and allows the sendmail program’s behavior to be observed while it runs in daemon mode.

As a daemon, sendmail does a listen(2) on TCP port 25 by default for incoming SMTP messages.[108] When another site connects to the listening daemon, the daemon performs a fork(2), and the child handles receipt of the incoming mail message.

-bH

Purge persistent host status V8.8 and later

The -bH command-line switch causes sendmail to clear (purge) all the persistent host-status information that was being saved as a result of the HostStatusDirectory option (HostStatusDirectory on page 1037). Note that the HostStatusDirectory directory is not itself removed, but all the subdirectories under it are. The purgestat(1) (purgestat (V8.8 or Later) on page 223) command-line command is a synonym for this switch.

Note that beginning with V8.10, sendmail only purges host-status files that exceed the timeout set by the Timeout.hoststatus option (Timeout.hoststatus (V8.8 and later) on page 1103).

-bh

Print persistent host status V8.8 and later

The -bh command-line switch is a synonym for the hoststat(1) command-line command. It causes sendmail to print its persistent host status and exit. See hoststat (V8.8 and Later) on page 221 for a description of this output.

-bi

Initialize alias databases All versions

The -bi command-line switch causes sendmail to rebuild its aliases(5) databases and then exit. This switch is described in Rebuild the Alias Database on page 478. The name newaliases and the (obsolete) -I command-line switch are synonyms for this mode.

-bm

Be a mail sender All versions

The -bm command-line switch (the default) causes sendmail to run once in the foreground. A list of recipients is taken from the command line (unless the -t command-line switch is used), and the message is read from the standard input and delivered.

This is the mode MUAs use when they invoke sendmail on the user’s behalf. The sendmail program processes the recipients first, then the message header, then the message body. Usually, the envelope recipients are those on the command line. But if the -t command-line switch is also used, the recipients are taken from the message header. The envelope sender is more difficult to determine:

  • Trusted users, and programs running under the identity of those users, can specify the address of the sender by using the -f command-line switch[109] (-f on page 241) when running sendmail. Trusted users are those that are declared with a T configuration command (Declare trusted users (ignored V8.1 through V8.6) on page 174). If anyone other than a trusted user uses the -f command-line switch, an X-Authentication-Warning: header (X-Authentication-Warning: on page 1167) will be added to the message to show that the sender was changed by an unauthorized user.

  • Otherwise, sendmail tries to use the user identity of the invoking program to determine the sender.

  • When generating a mail bounce message, the sender becomes the name specified by the value of the $n sendmail macro ($n on page 836), usually mailer-daemon.

-bP

Print number of messages in the queue V8.12 and later

The -bP command-line switch causes sendmail to print the number of messages currently queued and then exit. See Print the Number of Messages in the Queue on page 425 for a full description of how to use this command-line switch.

-bp

Print the queue All versions

The -bp command-line switch is a synonym for mailq(3). See Printing the Queue on page 422 for a full description of how to use this command-line switch.

-bs

Run SMTP on standard input All versions

The -bs command-line switch causes sendmail to run a single SMTP session in the foreground over its standard input and output, and then exit. The SMTP session is exactly like a network SMTP session. Usually, one or more messages are submitted to sendmail for delivery.

This mode is intended for use at sites that wish to run sendmail with the inetd(8) daemon. To implement this, place an entry such as the following in your inetd.conf(5) file, and then restart inetd(8) by killing it with a SIGHUP signal:

smtp   stream  tcp   nowait  root /usr/sbin/sendmail sendmail -bs

With this scheme it is important to either use cron(3) to run sendmail periodically to process its queue:[110]

0 * * * * /usr/sbin/sendmail -q

or run sendmail in the background to process the queue periodically by specifying an interval to the -q command-line switch’s interval (Periodically with -q on page 427):

/usr/sbin/sendmail -q1h

There are advantages and disadvantages to using inetd(8) instead of the -bd daemon mode to listen for and process incoming SMTP messages. The advantages are the following:

  • At security-conscious sites, sendmail can be hidden behind a tcpd(8) or miscd(8) wrapper that can selectively accept or reject connections. (But see TCPWRAPPERS in TCPWRAPPERS on page 147 for a way to include this support directly inside sendmail.)

  • At hosts that receive few incoming mail messages, this mode avoids the need to run a daemon.

The disadvantages are the following:

  • At sites that receive many incoming mail messages, this mode causes a new sendmail process to be started for each connection. Compared to daemon mode, this can adversely affect system performance.

  • At highly loaded sites, with older versions of inetd(8), this mode circumvents the sendmail program options that are intended to avoid overloading the system with too many concurrent sendmail processes.

In general, the inetd(8) approach should be used only on lightly loaded machines that receive few SMTP connections.

The -bs switch is also useful for MUAs that prefer to use SMTP rather than a pipe to transfer a mail message to sendmail. Depending on how it is configured, mh(1) can use this feature.

-bt

Rule-testing mode All versions

The -bt command-line switch causes sendmail to run in rule-testing mode. This mode is covered in detail in Chapter 8 on page 299.

-bv

Verify: don’t collect or deliver All versions

The -bv command-line switch causes sendmail to verify the list of recipients. Each recipient in the list of recipients is fully processed up to the point of delivery without actually being delivered. If mail can be successfully delivered to a recipient, sendmail prints a line such as one of the following:

name ...deliverable
name ...deliverable: mailer $# value, host $@ value, user $: value

The first form is that of pre-V8 sendmail. The second form began with V8.1 sendmail.

The name is the original recipient address after it has undergone aliasing and rule set rewriting. A local user’s name expands to the contents of that user’s ~/.forward file. A mailing list expands to many names (and produces many lines of output). The mailer, host, and user correspond to the triple returned by rule set 0 (The parse Rule Set 0 on page 696). If no $@ is returned, the host part is omitted from this output.

If the recipient cannot be delivered to, sendmail instead prints the following:

name ...reason

The reason the recipient is undeliverable can be explained by any of many possible error messages (such as “No such user”) that would prevent successful delivery.

The -bv switch also prevents sendmail from collecting any mail message from its standard input unless the -t command-line switch (-t on page 248) is also given.

Beginning with V8.12, the restrictexpand keyword for the PrivacyOptions option causes sendmail to drop special privileges when the -bv switch is specified by a user who is neither root nor a trusted user. This prevents ordinary users from reading ~/.forward files, :include: files, and private aliases (aliases found in aliases files that are not ordinarily readable). The restrictexpand keyword also prevents the -v switch from being used.

-bz

Freeze the configuration file Not V8

Prior to V8 sendmail, the -bz command-line switch caused sendmail to build (or rebuild) its frozen configuration file (now obsolete). The frozen configuration file was just a simple image of sendmail’s variables after it had read and parsed the configuration file. The purpose of the frozen file was to enable sendmail to start up more swiftly than it could when parsing the configuration file from scratch.[111]

The -bz command-line switch is obsolete. If you use it with V8 and higher sendmail, you will see this error message:

Frozen configurations unsupported

-C

Location of the configuration file All versions

The -C command-line switch tells sendmail where to find its configuration file. The form of the -C switch is:

-C path

With V8 sendmail, space between the -C and the path is optional. The path specifies the location of the configuration file. That location can be either a relative or a full pathname. If path is missing, the location becomes the file sendmail.cf in the current directory.

The -C command-line switch causes sendmail to internally mark the configuration file as unsafe. An unsafe configuration file prevents all but root from setting certain options and causes sendmail to change its uid and gid to that of the user that ran it. If it is used by someone other than the superuser (and not in the -bt rule-testing mode), the -OQueueDirectory=path switch should also be used to set the location of the queue directory. If that location is not changed, sendmail fails because it cannot chdir(2) into its queue directory.

Prior to V8, the -C command-line switch also prevented sendmail from “thawing” its frozen configuration file.

One practical use for this command-line switch might be as part of a make(1) file that is used to generate a cf file from your mc file. Consider, for example, that you maintain the mc source for your configuration file in a directory that is separate from the sendmail source directory. If such a directory were /usr/local/src/sendmail/cf, and if the sendmail source were located in /usr/local/src/sendmail/8.12.7, you could create a Makefile something like this in the cf directory:

M4=/usr/ccs/bin/m4                           ← for Solaris 5.4
CFDIR=../sendmail-8.12.7/cf/
MC_FILE=yourhost                             ← the base name of your mc file
SENDMAIL=/usr/sbin/sendmail                  ← where your sendmail is located
create:
        @echo building
        @$(M4) -D_CF_DIR_=$(CFDIR) $(CFDIR)m4/cf.m4 ${MC_FILE}.mc > ${MC_FILE}.cf
        @echo testing
        @$(SENDMAIL) -C${MC_FILE}.cf -bt < /dev/null > /dev/null;
install:
        mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.save
        cp ${MC_FILE}.cf /etc/mail/sendmail.cf

Thereafter, to generate and install a new configuration file you just run the following commands:

% cd /usr/local/src/sendmail/cf
% make
building
testing
% sudo make install
mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.save
cp yourhost.cf /etc/mail/sendmail.cf
%

As you gather more machines to administer, you can centralize many mc files in one place and update the configuration files with a single command.

-c

Set HoldExpensive option to true Deprecated

The -c command-line switch is a synonym for the HoldExpensive option (HoldExpensive on page 1036).

As of V8, this command-line switch has been deprecated and might not be included in future versions. Note that -oc is still a legal form of shorthand that sets the HoldExpensive option to true.

-D

Write debugging output to a file V8.13 and later

The -D command-line switch causes sendmail to redirect sendmail’s debugging output (The Syntax of -d on page 530) into a file for later examination. It is used like this, where file is the name of an existing or new file:

-D file

The -D command-line switch (if used) must precede all -d switches on the same command line. Otherwise, the following error will print and all debugging output will be printed to the standard output (possibly causing you to miss seeing the error):

-D file must be before -d

The file specified with -D must live in a directory that is writable by the user running sendmail. If the file does not exist, it will be created. If the file already exists, it will be silently appended to.

Extra care must be exercised when using the -D command-line switch when sendmail is run as root because the target file will be appended to, even if it is a symbolic link to an important file. For example, when /tmp/foo is a non-root owned symbolic link that points to /etc/passwd, the following command line, when run by root, will silently append debugging information to the /etc/passwd file:

# /usr/sbin/sendmail -D /tmp/foo -d0.1 -bt < /dev/null

-d

Enter debugging mode All versions

The -d command-line switch causes sendmail to run in debugging mode. This switch is described in gory detail in Chapter 15 on page 530.

-E

Japanese font conversion Sony NEWS only

The -E switch is reserved for the Sony NEWS adaptation of sendmail. It is ignored by the Berkeley release of V8 sendmail and produces no errors if used by that version.

-e

Set the ErrorMode option’s mode Deprecated

The -e command-line switch is a synonym for the ErrorMode option (ErrorMode on page 1028).

The -e command-line switch is deprecated and might not be included in future versions. Note that -oe is still a legal form of shorthand that sets the ErrorMode option to true.

-F

Set the sender’s full name All versions

The -F command-line switch specifies the full name of the sender, which is used in mail headers and the envelope. The form of the -F switch is:

-Ffullname
-F fullname

Space between the -F and the fullname is optional. If fullname is missing and the -F is the last argument, sendmail prints the following error and exits:

sendmail: option requires an argument -- F

If the -F is followed by any other switches, the following switch is taken as the full name.

When specifying the sender’s full name, be sure to quote any internal spaces or shell special characters. For example, for the C shell the following would be needed to specify the full name Happy Guy!:

"Happy Guy\!"

In the absence of this switch, sendmail finds the sender’s full name in any of several places. These are described in the section discussing the $x sendmail macro ($x on page 851).

The -F command-line switch is used by programs and shell scripts that send email. Consider the following administrative shell script that is run by cron(8) once per night:

#!/bin/sh
DISKUSE="du -s"
ARCHDIR=/admin/mail/lists
LIMIT=10
NOTIFY=root@localhost

# Run this nightly to detect an overgrown archive directory
BLOCKS=`$DISKUSE $ARCHDIR | awk '{print $1}'`
if [ $BLOCKS -gt $LIMIT ]; then
        echo $BLOCKS over $LIMIT in $ARCHDIR |\
        /usr/sbin/sendmail -F"DU Report by root" -f du-report $NOTIFY
fi

Here, in the full-name portion of the From: header, the delivered warning email message will include the notation “DU Report by root”:

From: "DU Report by root" <du-report@your.domain>

-f

Set sender’s address All versions

The -f command-line switch[112] causes sendmail to take the address of the sender from the command line rather than from the envelope or message header. The -f switch is used by UUCP software and by mailing list software. The form of the -f switch is:

-faddr
-f addr

Space between the -f and the addr is optional. If addr is missing, sendmail prints the following error message and ignores the -f switch:

sendmail: option requires an argument -- f

Multiple -f switches cause sendmail to print the following error message and exit:

More than one "from" person

The behavior of this switch varies depending on the version of sendmail you are running.

Prior to V8, the uid of the user specifying the -f switch must match one of the usernames given in the T configuration command. If they do not match, sendmail silently ignores the option and determines the sender’s address in the usual ways.

From V8.1 through V8.6, the T configuration command was eliminated. If the -f or -r switch was used, and if the p (privacy) option was given authwarnings, sendmail included an X-Authentication-Warning: header in the mail message. That header warned that the identity of the sender had changed.

Beginning with V8.7 sendmail, the T was reintroduced, but in a different form (Trusted Users on page 173). First sendmail checks to see whether the user specified by the -f is the same as the login name of the user running sendmail, as would be the case for mh(1). If they are the same, sendmail silently accepts the address. If they differ, sendmail looks to see whether the login name of the user running sendmail is in the class $=t. If it is, sendmail silently accepts the address. If not, sendmail checks to see whether authwarnings is set for the PrivacyOptions option (PrivacyOptions on page 1065). If it is, the following warning is logged and included in the outgoing message:

X-Authentication-Warning: login set sender to new name using -f

An example of one use for the -f switch can be seen in the previous section covering the -F switch.

-G

Set gateway submission mode V8.10 and later

Use of the -G command-line switch indicates to sendmail that the message being submitted from the command line is for relaying, and is not an initial submission. This switch is primarily intended for use by the rmail(8) program, a part of the UUCP suite of programs. Mail received by UUCP is mail that did not originate at the local site. It is intended to be relayed outward to other sites, or to be delivered locally. Because mail received by UUCP is not the initial (therefore, local) submission of a message, sendmail needs to be more strict about what it will accept.

A message received with the -G switch specified will be rejected if the address is not fully qualified. The -G command-line switch also tells sendmail to perform no canonicalization on the address. Note that future releases of sendmail might reject improperly formed messages when this switch is specified.

-h

Initial hop count Deprecated

A hop is the transmittal of a mail message from one machine to another. Many such hops can be required to deliver a message. The number of hops (the hop count) is determined by counting the number of Received:[113] header lines in the header portion of an email message. The maximum number of allowable hops is compiled in for most versions of sendmail but is set by the MaxHopCount option with V8. When the hop count for a message exceeds the limit set by the MaxHopCount option (MaxHopCount on page 1046), the message is bounced. Ordinarily, the count begins at zero. The -h command-line switch is used to specify a beginning hop count.

The forms for the -h command-line switch are:

-hnum
-h num

Space between the -h and num is optional. If num is missing, sendmail prints the following error message and ignores that switch:

sendmail: option requires an argument -- h

If num begins with a character other than a digit, the offending text is printed:

Bad hop count (bad text)

The previous failure illustrates that the minimum hop count must be positive.

The -h switch was originally used by BerkNet to carry the hop count in the envelope. It currently has no application.

-I

Synonym for -bi Deprecated

The -I command-line switch is a synonym for the -bi command-line switch and the newaliases name. It is obsolete but retained for compatibility with the delivermail(1) program (the precursor to sendmail).

The -I switch is deprecated and might not be included in future versions of sendmail. The -I switch is present only if sendmail was built with DBM defined.

-i

Set the IgnoreDots option to true Deprecated

The -i command-line switch is a synonym for the IgnoreDots option (IgnoreDots on page 1038).

The -i switch is deprecated and might not be included in future versions. Note that -oi is still a legal form of shorthand that sets the IgnoreDots option to true.

-J

Japanese font conversion Sony NEWS only

The -J switch is reserved for the Sony NEWS adaptation of sendmail. It is ignored by the Berkeley release of V8 sendmail and produces no errors if used by that version.

-L

Syslog label V8.10 and later

Ordinarily, when sendmail logs a message with the syslog(8) facility, it does so using the name “sendmail.” For example, the first part of a typical syslog(8) entry might look like this:

Mar  1 11:30:48 your.host.domain sendmail[18754]: f21IUUxl018753: to=...

The name “sendmail” usually precedes the process ID number, which is set off in square braces.

Beginning with V8.10 sendmail, it is now possible to change the name used by sendmail when it logs into a new name of your choice. This is done by using the -L command-line switch. To illustrate, consider this line from a typical /etc/init.d/sendmail system startup file:

/usr/sbin/sendmail -bd -q30m;

At some sites, administrators prefer to run the listening daemon (the -bd) separately from the queue processing daemon (the -q30m). At such sites, the system startup file might be rewritten (in part) like this:

/usr/sbin/sendmail -Lsendmail-listen -bd;
/usr/sbin/sendmail -Lsendmail-queue -q30m;

Here, the listening daemon will log its messages using the name “sendmail-listen” and the queue handling daemon will log its messages using the name “sendmail-queue.”

Note that if users other than root or trusted users use this switch, it will cause sendmail to syslog(8) a message such as the following:

user uid changed syslog label

-M

Define a sendmail macro on the command line V8.7 and later

The -M command-line switch is used to assign a sendmail macro a value. Note that prior to V8.8, only single-character sendmail macro names could be defined. The -M command-line switch is fully described in Command-Line Definitions on page 786.

-m

Set the MeToo option to true Deprecated

The -m command-line switch is a synonym for the MeToo option. It is used to set that option to true. The -m command-line switch is fully described in MeToo on page 1051.

Note that as of V8.10, the default for the MeToo option is set to true. Also note that as of V8.12 sendmail, this command-line switch is now deprecated.

-N

Specify DSN NOTIFY information V8.8 and later

The -N command-line switch causes sendmail to append the DSN NOTIFY command to the ESMTP RCPT command. For example:

RCPT To:<friend@other.site> NOTIFY=SUCCESS

Here, sendmail is requesting that the other site return notification of successful delivery.

The -N command-line switch also causes sendmail to behave as though it got the NOTIFY command when producing a local bounce message. That is, -N affects the other sites’ behavior on SMTP mail, and the local site’s behavior on local delivery.

Should the message be successfully delivered by a host that understands DSN, or by the local host, a return message will be sent to the sender. If either site is running V8.8 or later sendmail, that return message will look (in part) like this:

Date: Fri, 14 Dec 2007 08:11:43 −0800 (PST)
From: Mail Delivery Subsystem <MAILER-DAEMON>
Subject: Return receipt
Message-Id: <200712142144.f21IuJf8029510@other.site>
To: <you@your.site>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
        boundary="f21IuJf8029510.834702270/other.site
Auto-Submitted: auto-generated (return-receipt)

This is a MIME-encapsulated message

--f21IuJf8029510.834702270/other.site

The original message was received at Fri, 14 Dec 2007 08:11:43 −0800 (PST)
from other.site [204.255.152.62]

   ----- The following addresses had successful delivery notifications -----
friend (successfully delivered to mailbox)

The -N command-line switch tells the NOTIFY command what to include and thus tunes how notification will be handled. The form of the -N command-line switch looks like this:

-Nnever
-Nkeyword,keyword,...

The first form sets NOTIFY to be NEVER, meaning send no notification. The second form tells NOTIFY to specify notification based on one or more of three possibilities:

success

The success keyword tells sendmail to ask for notification of successful final delivery.

failure

The failure keyword tells sendmail to ask for notification if the message fails to be delivered.

delay

The delay keyword tells sendmail to ask for notification if the message is delayed for any reason.

These keywords can be listed after the -N to set a combination of notification requests. For example:

-Ndelay,success

This tells sendmail to ask for notification if the message is successfully delivered or delayed but not to get notification if the message fails.

If an unknown keyword is listed, sendmail prints the following error message and ignores the bad keyword:

Invalid -N argument

If the -N command-line switch is omitted, notification policy is left to the other site. The usual default is failure (and possibly delay). On the local machine, sendmail acts as though both failure and delay were specified.

-n

Don’t do aliasing All versions

The -n command-line switch prevents sendmail from changing local recipient addresses with aliases. The -n switch is fully described in Prevent Aliasing with -n on page 482.

-O

Set multicharacter option V8.7 and later

The -O command-line switch is used to set a multicharacter configuration option from the command line:

-OLongName=value

The -O switch is described in detail in Command-Line Options on page 948.

-o

Set a single-character option All versions

The -o command-line switch is used to set a single-character configuration option from the command line:

-oXvalue

The -o switch is described in detail in Command-Line Options on page 948.

-p

Set protocol and host V8.10 and later

The $r sendmail macro ($r on page 842) holds as its value the protocol that is used in receiving a mail message (usually SMTP or UUCP). The $s sendmail macro ($s on page 844) holds as its value the name of the sending host. Some programs, such as UUCP, need to be able to set the values of these macros from the command line. The old way to set them looked like this:

-oMrUUCP -oMslady

Here, the M option sets $r to be UUCP and $s to be lady.

Under V8 sendmail, the setting of $r and $s has been simplified. A command-line single switch, -p, can be used to set them both:

-prval:sval

Here, the rval is the value assigned to $r, and the sval is the value assigned to $s. The two are separated by a colon. If the sval is omitted, the colon should also be omitted.

-Q

Quarantine an envelope V8.13 and later

The -Q command-line switch causes sendmail to quarantine an envelope. See The -Q command-line switch on page 440 for a full description in context with quarantining in general.

-q

Process the queue All versions

The -q command-line switch causes sendmail to process its queue once or periodically, depending on its arguments. The -q switch is described in detail in Periodically with -q on page 427.

-R

What DSN info to return on a bounce V8.8 and later

The -R command-line switch tells sendmail to include the DSN RET command with an ESMTP MAIL command:

MAIL From:<you@your.host> RET=full
MAIL From:<you@your.host> RET=hdrs

The RET command requests the receiving site to (or not to) include a copy of the original message body in the bounced mail notification. RET=full requests that both headers and the message body be returned. RET=hdrs requests that only headers be returned. The RET= command affects the receiving site only if it agrees to handle the DSN extension to ESMTP. In the absence of RET or remote DSN support, the receiving site is free to return the message body if it so desires.

For local mail, sendmail uses this -R command-line switch to determine how it will handle local bounces. Normally, sendmail includes everything (full) in a locally generated bounce. By using hdrs, you can restrict local bounces to only the header portions of the original message.

The RET, and hence this -R command-line switch, is useful in two circumstances:

  • For users sending email, this should be set to full so that any bounced mail will include the original message body. This helps to reduce the need for users to archive their outgoing mail.

  • For mailing-list mailings or other batched broadcast messages, this should be set to hdrs so that only the header portion of the bounced message will be returned.

The form of the -R command-line switch looks like this:

-R arg

Space between the -R and its argument is optional. The arg must be present and must be either hdrs (return only headers) or full (return the body too). If it is any other value, the following error is printed and the setting defaults to full:

Invalid -R value

The -R command-line switch can appear only once in the command line. If it appears multiple times, the second and subsequent appearances will result in this error message:

Duplicate -R flag

Beginning with V8.10, sendmail allows you to set a policy of not returning the body, regardless of what is requested by the sending site. You do this by setting the PrivacyOptions=nobodyreturn option (PrivacyOptions=nobodyreturn on page 1066).

-r

Set sender’s address Deprecated

The -r command-line switch is a synonym for the -f command-line switch. This -r command-line switch is deprecated and might not be included in future versions.

-s

Set the SaveFromLine option to true Deprecated

The -s command-line switch tells sendmail to set the SaveFromLine option (SaveFromLine on page 1085) to true. This -s command-line switch is deprecated and might not be in future versions. Note that -os is still a legal form of shorthand that sets the SaveFromLine option to true.

-T

Set the QueueTimeout option Deprecated

The -T command-line switch causes sendmail to set the QueueTimeout option (QueueTimeout on page 1075) to the value specified. This -T command-line switch is deprecated (as is the QueueTimeout option) in favor of the Timeout option of V8.7 sendmail (Timeout on page 1097) and might not be included in future versions of sendmail. Note that -oT is still a legal form of shorthand to set the value of the QueueTimeout option.

-t

Get recipients from message header All versions

The -t command-line switch causes sendmail to gather its list of recipients from the message’s header in addition to gathering them from its command line. The -t switch takes no arguments.

When this switch is specified, sendmail gathers recipient names from the To:, Cc:, and Bcc: header lines. It also gathers recipient names from its command line if any were listed. Duplicates are discarded, the Bcc: header is stripped, and the message is delivered.

The -t switch is intended for use by MUAs. It should never be specified when sendmail is run in daemon mode.

-U

This is the initial MUA-to-MTA submission V8.8 through V8.11

The -U command-line switch is used to tell sendmail that this is the very first step in this email message’s submission.

From V8.8 through V8.11, this switch did nothing. Beginning with V8.12, this switch was eliminated, and the default behavior of sendmail was changed. Now sendmail presumes that any message’s submission is an initial submission unless the -G command-line switch is present.

-V

Specify the ENVID string V8.8 and later

The -V command-line switch is used to specify the envelope identifier for the outgoing message. That identifier is called the ENVID and is part of the DSN extension to ESMTP. ENVID and the ${envid} sendmail macro are fully discussed in ${envid} on page 823.

The form of the -V command-line switch looks like this:

-Venvid
-V envid

Space between the -V and its argument is optional. The envid must be a legal ENVID identifier. If an illegal character is specified in envid, the following error is printed, and that declaration is ignored:

Invalid syntax in -V flag

-v

Run in verbose mode All versions

The -v command-line switch tells sendmail to run in verbose mode. In that mode, sendmail prints a blow-by-blow description of all the steps it takes in delivering a mail message.

After the sendmail.cf file is parsed and after the command-line arguments have been processed, sendmail checks to see whether it is in verbose mode. If it is, it sets the HoldExpensive option (HoldExpensive on page 1036) to false and sets the DeliveryMode option to interactive (DeliveryMode=interactive on page 1006).

The -v switch is most useful for watching SMTP mail being sent and for producing expanded output when viewing the queue.

The modified -v verbose switch with the MSP

Since V8.12, sendmail has run as non-set-user-id root. One problem with this scheme is that only the connection between the MSP sendmail and the local listening daemon is viewable when using the -v command-line switch. This restriction made it difficult to diagnose certain sending problems in the traditional manner.

Beginning with V8.13, the -v command-line switch causes the MSP sendmail to send the SMTP VERB (verbose) command to the local listening daemon. This causes the local listening daemon to print (as part of its SMTP replies) each step of what it is doing to send the message out over the Internet.

In the following examples, we first show a verbose run with V8.12 sendmail:

% /usr/sbin/sendmail -v you@someother.site < /dev/null
you@someother.site... Connecting to localhost via relay...
220 your.site ESMTP Sendmail 8.12.9/8.12.9; Sun, 7 Sep 2003 15:48:23 −0600 (MDT)
>>> EHLO your.site
250-your.site Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES...etc.

Note that under V8.12, all you could see was the conversation between the MSP sendmail and the local listening daemon. But beginning with V8.13, the -v command-line switch causes additional information to be printed, as shown in the following code. Note that each additional line is prefixed with a 050 SMTP reply code:

050 <you@someother.site>... Connecting to someother.site. via esmtp...
050 220 someother.site ESMTP Sendmail 8.13.0/8.13.0; Sun, 7 Sep 2003 15:55:35 −0600
(MDT)
050 >>> EHLO your.site
050 250-someother.site Hello your.site [192.168.5.12], pleased to meet you
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-8BITMIME
050 250-SIZE
050 250-DSN050 250-ETRN
050 250-DELIVERBY
050 250 HELP
050 >>> MAIL From:<you@your.site> SIZE=294
...etc.

Note that the -v command-line switch will put the local listening daemon into verbose mode only if the configuration file for that daemon omits both the noverb (PrivacyOptions=noverb on page 1068) and goaway (PrivacyOptions=goaway on page 1066) PrivacyOptions option’s settings.

define(`confPRIVACY_FLAGS',`noverb')    ←omit this
define(`confPRIVACY_FLAGS',`goaway')    ←omit this

If either option is declared, the local listening daemon will not go into verbose mode, and no additional information will print.

-X

Log transactions V8.1 and later

The -X command-line switch tells sendmail to open the file whose name is the next following argument and to append both sides of all SMTP transactions to that file. The -X command-line switch is described in full in Log Transactions with -X on page 512.

Note that this -X command-line switch causes sendmail to drop special privileges when run by an ordinary user.

-x

Ignored OSF and AIX 3.x only

V8 sendmail prints an error if an illegal switch is specified (whereas other versions of sendmail silently ignore them). The mailx program that is supplied with OSF/1 and AIX issues an illegal -x switch. To keep sendmail from uselessly complaining under OSF/1 and AIX, that switch is specifically ignored. To get the same behavior with AIX under V8.1 sendmail, look for _osf_ in main.c and uncomment the code necessary to ignore that switch.



[103] * On SunOS 4.x systems you will find /usr/lib/sendmail.mx for use with the Domain Name System (DNS).

[104] * Prior to V8 sendmail, whitespace was not allowed between the letter and the argument.

[105] * Under pre-V8 sendmail, recipient names could never begin with a -C, -b, -d, -q, or -Z. If any did, they were wrongly interpreted as switches during preprocessing.

[106] And its derivatives such as tcsh(1).

[107] * In its classic invocation, -bd is usually combined with a -q1h.

[108] Beginning with V8.10, sendmail also listens on port 587 for message submissions via MUAs. This default behavior can be turned off with the FEATURE(no_default_msa) (FEATURE(no_default_msa) on page 635).

[109] * The -r is a synonym for -f, but -r is deprecated, so we don’t mention it directly.

[110] * The look of these lines varies depending on the version of Unix you are running.

[111] * In practice, freeze files helped you only on systems with very fast I/O relative to their CPU speeds. Although this was true in the day of the VAX 11/750, improvements in processor technology have reversed this trade-off.

[112] * The -r command-line switch is a synonym for this -f switch, but the -r is deprecated and should not be used.

[113] * Actually, all headers marked with the H_TRACE flag in conf.c (H_TRACE Header Flag (V5 and Later) on page 1142) are counted.