sendmail

send mail over the Internet

Syntax:

sendmail [options] [address...]

Options:

-ba
Enter ARPANET mode. All input lines must end with a CR/LF, and all messages will be generated with a CR/LF at the end. Also, the From: and Sender: fields are examined for the name of the sender.
-bd
Run as a daemon. The sendmail utility will fork and run in the background, listening on socket 25 for incoming SMTP connections. This is normally run from /etc/sysinit.node.
-bi
Initialize the alias database.
-bm
Deliver mail in the usual way (default).
-bp
Print a listing of the queue.
-bs
Use the SMTP protocol described in RFC 821 on the standard input and the standard output. This option implies all the operations of the -ba option that are compatible with SMTP.
-bt
Run in address test mode. This mode, which reads addresses and shows the steps in parsing, is used for debugging configuration tables.
-bv
Verify names only; don't try to collect or deliver a message. This mode is normally used for validating users or mailing lists.
-C file
Use the specified alternate configuration file. The sendmail utility refuses to run as root if an alternate configuration file is specified.
-d X
Set debugging level to X.
-F fullname
Set the full name of the sender as fullname.
-f name
Set the name of the ``from'' person (the sender of the mail) as name. This option can be used only by ``trusted'' users (normally root) or by you if the person you're trying to become is yourself.
-h N
Set the hop count to N. The hop count is incremented every time the mail is processed. When it reaches a limit, the mail is returned with an error message, the victim of an aliasing loop. If this isn't specified, Received: lines in the message are counted.
-n
Don't do aliasing.
-o x value
Set option x to the specified value. See ``Processing options,'' below.
-q [time]
Process saved messages in the queue at given intervals. If time is omitted, process the queue once. If time is specified, run in the background.

The time argument is given as a tagged number, with s for seconds, m for minutes, h for hours, d for days, and w for weeks. For example, -q1h30m or -q90m would both set the timeout to one hour, thirty minutes.

You can use this option safely with -bd.

-r name
A deprecated form of the -f option.
-t
Read message for recipients. The To:, Cc:, and Bcc: lines will be scanned for recipient addresses; the Bcc: line will be deleted before transmission. Any addresses in the argument list will be suppressed (i.e. they won't receive copies even if listed in the message header).
-v
Be verbose: announce alias expansions, etc.

Processing options

The following processing options are normally used only by the system administrator. They may be set either on the command line using the -o option or in the configuration file.

Afile
Use this alternate alias file.
c
On mailers that are considered ``expensive'' to connect to, don't initiate immediate connection. This requires queueing.
dx
Set the delivery mode to x. Delivery modes are:
i
interactive (synchronous) delivery
b
background (asynchronous) delivery
q
queue only; actual delivery takes place the next time the queue is run
D
Try to automatically rebuild the alias database, if necessary.
ex
Set error processing to mode x. Valid modes are:
e
Do special processing for the BerkNet.
m
Mail back the error message.
p
Print the errors on the terminal (default).
q
Throw away error messages (only exit status is returned).
w
``Write'' back the error message (or mail it back if the sender isn't logged in).

If the text of the message isn't mailed back by modes m or w and if the sender is local to this machine, a copy of the message is appended to the dead.letter file in the sender's home directory.

Fmode
Use this mode when creating temporary files.
f
Save UNIX-style ``From'' lines at the front of messages.
g N
The default group ID to use when calling mailers.
Hfile
The SMTP help file.
i
Don't take dots on a line by themselves as a message terminator.
k N
Checkpoint the queue file after every N successful deliveries (default is 10). This avoids excessive duplicate deliveries when sending to long mailing lists interrupted by system crashes.
Ln
The log level.
m
Send to ``me'' (the sender) also if I'm in an alias expansion.
o
If o is specified, this message may have old-style headers. Without o, this message is guaranteed to have new-style headers (i.e. commas instead of spaces between addresses). With o, an adaptive algorithm is used that will correctly determine the header format in most cases.
Qqueuedir
Queue messages in the specified directory.
rtimeout
Use this timeout on reads. If no timeout is set, sendmail will wait forever for a mailer. This option violates the word (if not the intent) of the SMTP specification, so the timeout should be fairly large.
Sfile
Save statistics in the named file.
s
Always instantiate the queue file, even when it isn't strictly necessary. This provides safety against system crashes during delivery.
Ttime
Set the timeout on undelivered messages in the queue to the specified time (default is three days). After delivery has failed (e.g. because of a host being down) for this amount of time, failed messages will be returned to the sender.
tstz, dtz
Set the name of the timezone.
uN
Use this as the default user ID for mailers.
w
If w isn't specified, name server lookups will use an ANY querytype to find types CNAME, A, and MX, and will cause all existing records to be cached by our local server.

If there's a wildcard MX in the local domain or in its parents, you must set this option, which will use a CNAME querytype only; if you don't, all fully qualified names will match as names in the local domain.

Description:

The sendmail utility sends a message to one or more recipients, routing the message over whatever networks are necessary. The utility does any inter-network forwarding necessary to deliver the message to the correct place.

Note that sendmail isn't intended as a user-interface routine; other programs provide user-friendly front ends. The utility is used only to deliver preformatted messages.

With no options, sendmail reads its standard input up to an end-of-file or a line consisting only of a single dot and then sends a copy of the message found there to all of the addresses listed. It determines the network(s) to use based on the syntax and contents of the addresses.

Local addresses are looked up in a file and aliased appropriately. You can prevent aliasing by preceding the address with a backslash. Normally the sender isn't included in any alias expansions, e.g. if john sends to group, and group includes john in the expansion, the letter won't be delivered to john.

If invoked as newaliases, the sendmail utility will rebuild the alias database. If invoked as mailq, the utility will print the contents of the mail queue.

Aliases

In aliases, the first character of a name may be a vertical bar; if so, the rest of the name is interpreted as a command to pipe the mail to. You may have to quote the name to keep sendmail from suppressing the blanks from between arguments. For example, a common alias is:

msgs: "|/usr/bin/msgs -s"

Aliases may also have the syntax :include:filename to ask sendmail to read the named file for a list of recipients. For example, an alias such as:

poets: ":include:/usr/local/lib/poets.list"

would read /usr/local/lib/poets.list for the list of addresses making up the group.

Files:

Except for the file /etc/sendmail.cf itself, the following pathnames are all specified in /etc/sendmail.cf. These values are only approximations.

/etc/aliases
Raw data for alias names.
/etc/sendmail.cf
Configuration file.
/etc/sendmail.hf
Help file.
/usr/spool/queue/*
Temp files.
/usr/spool/sendmail.st
Collected statistics.

Exit status:

The sendmail utility returns an exit status describing what it did. The codes are defined in sysexits.h:

EX_CANTCREAT
Output file can't be created.
EX_DATAERR
User input data incorrect.
EX_IOERR
I/O error on a file.
EX_NOHOST
Hostname doesn't exist.
EX_NOINPUT
User input file doesn't exist.
EX_NOPERM
Insufficient permission to perform the operation.
EX_NOUSER
Username doesn't exist.
EX_OK
Successful completion on all addresses.
EX_OSERR
Temporary operating system error, such as ``cannot fork.''
EX_OSFILE
System file (e.g. /etc/passwd) doesn't exist, can't be opened, or has some sort of error (such as a syntax error).
EX_PROTOCOL
Remote system returned something that wasn't possible during a protocol exchange.
EX_SOFTWARE
Internal software error, including bad arguments.
EX_TEMPFAIL
Message couldn't be sent immediately, but was queued.
EX_UNAVAILABLE
Catchall meaning necessary resources weren't available.
EX_USAGE
Command incorrect. Might be the wrong number of arguments, or a bad flag, etc.

Caveats:

Support isn't available for the frozen sendmailconfiguration file.

See also:

mailx, mailq, rmail, smtpd, /etc/sendmail.cf file

RFC 819, RFC 821, RFC 822

Sendmail by Bryan Costales, O'Reilly & Associates (ISBN 1-56592-056-2)