On Unix-like operating systems, sendmail is a general purpose e-mail routing facility that supports many kinds of mail-transfer and delivery methods, including the SMTP (Simple Mail Transfer Protocol) used for e-mail transport over the Internet.

Description

sendmail sends a message to one or more recipients, routing the message over whatever networks are necessary. sendmail does internetwork forwarding as necessary to deliver the message to the correct place.

  • Description
  • Syntax
  • Alternate syntax
  • Parameters
  • Exit Status
  • Alternate invocations
  • Files
  • Examples
  • Related commands
  • Linux commands help

sendmail is not intended as a user interface routine; other programs provide user-friendly front ends. sendmail is used only to deliver pre-formatted messages.

With no flags specified, sendmail reads its standard input up to an end-of-file or a line consisting only of a single dot, and 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. Aliasing can be prevented by preceding the address with a backslash. Beginning with version 8.10, the sender is included in any alias expansions; for example, if “john” sends mail to “group”, and “group” includes “john” in the expansion, then the letter also delivers to “john”.

Syntax

sendmail [flags] [address …]

Alternate syntax

sendmail can also be invoked, with special functionality, using the following commands.

newaliases

mailq [-v]

hoststat

purgestat

smtpd

See below for more information.

Parameters

Options

There are also many processing options that can be set. Normally these are only used by a system administrator. Options may be set either on the command line using the -o flag (for short names), the -O flag (for long names), or in the configuration file. This is a partial list limited to those options that are likely to be useful on the command line and only shows the long names. The options are:

In aliases, the first character of a name may be a vertical bar ("|") to cause interpretation of the rest of the name as a command that pipes the mail. It may be necessary 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.

Exit status

Sendmail returns an exit status describing what it did. The exit codes are listed below, and defined in <sysexits.h>.

Alternate invocations

If invoked as newaliases, sendmail will rebuild the alias database.

If invoked as mailq, sendmail prints the contents of the mail queue.

If invoked as hoststat, sendmail prints the persistent host status database.

If invoked as purgestat, sendmail purges expired entries from the persistent host status database.

If invoked as smtpd, sendmail acts as a daemon, as if the -bd option were specified.

Files

Except for the file /etc/mail/sendmail.cf itself, the following pathnames are all specified in /etc/mail/sendmail.cf. Thus, these values should only be considered approximations.

Examples

sendmail [email protected]

sendmail will read your e-mail from standard input, and attempt to send the e-mail when you enter a single dot (".") on a new line and press Enter. For example, after running the above command, you could type:

From: [email protected] To: [email protected] Hi, this is my message, and I’m sending it to you! .

and sendmail attempts to send it.

biff — Receive detailed mail notifications at the command line.mail — Read, compose, and manage mail.mailx — Process mail messages.newalias — Install new elm aliases.pine — A client for using mail and newsgroups.