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:
-X
Boolean switch
-Xarg
switch with argument
All switches are single letters. The complete list is shown in Table 36.2.
Switch | Version | Description | |
---|---|---|---|
-B
| -B | and above | Specify message body type |
-b
| -b | All versions | Set operating mode |
-ba
| -ba | Not V8.1- V8.6 | Use ARPAnet/Grey Tutorial protocols |
-bD
| -bD | and above | Run as a daemon, but don't fork |
-bd
| All versions | Run as a daemon | |
-bH
| and above | Purge persistent host status | |
-bh
| -bh | and above | Print persistent host status |
-bi
| All versions | Initialize alias database | |
-bm
| -bm | All versions | Be a mail sender |
-bp
| All versions | Print the queue | |
-bs
| -bs | All versions | Run SMTP on standard input |
-bt
| "Overview" | All versions | Rule testing mode |
-bv
| -bv | All versions | Verify: don't collect or deliver |
-bz
| -bz | Not V8 | Freeze the configuration file |
-C
| -C | All versions | Location of configuration file |
-c
| HoldExpensive (c) | Deprecated | Set HoldExpensive (c) option to true |
-d
| "The Syntax of -d" | All versions | Enter debugging mode |
-E
| -E | Sony NEWS only | Japanese font conversion |
-e
| ErrorMode (e) | Deprecated | Set the ErrorMode (e) option's mode |
-F
| -F | All versions | Set the sender's full name |
-f
| -f and -r | All versions | Set sender's address |
-h
| -h | Deprecated | Minimum hop count |
-I
| -I | Deprecated | Synonym for -bi
|
-i
| -i | Deprecated | Set the IgnoreDots (i) option to true |
-J
| -J | Sony NEWS only | Japanese font conversion |
-M
| "Command-Line Definitions" | and above | Define a macro on the command line |
-m
| MeToo (m) | All versions | Set the MeToo (m) option to true |
-N
| -N | and above | Specify DSN NOTIFY information |
-n
| "Prevent Aliasing with -n" | All versions | Don't do aliasing |
-O
| "Command-Line Options" | and above | Set a multicharacter option |
-o
| All versions | Set a single-character option | |
-p
| -p | and above | Set protocol and host |
-q
| All versions | Process the queue | |
-R
| -R | and above | DSN what to return on a bounce |
-r
| Deprecated | Synonym for -f
| |
-s
| SaveFromLine (f) | Deprecated | Set the SaveFromLine (f) option to true |
-T
| QueueTimeout (T) | Deprecated | Set QueueTimeout (T) option |
-t
| -t | All versions | Get recipients from message header |
-U
| -U | and above | This is the initial MUA to MTA submission |
-V
| -V | and above | Specify the ENVID string |
-v
| All versions | Run in verbose mode | |
-X
| "Log Transactions with -X" | and above | Log transactions |
-x
| -x | and above | 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 may immediately follow the letter or be separated from it with whitespace: [2]
[2] Prior to V8 sendmail, whitespace was not allowed between the letter and the argument.
-Ctest.cfgood -C test.cf
also good
The only exception to this rule is the -d
command-line switch (set debugging mode). It may not have whitespace between the letter and the arg
.
Some switches, such as -q
(process the queue), can either be Boolean or take an argument:
-qboolean -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 may 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/lib/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. [3]
[3] 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.