LinuxCommandLibrary

ssmtp

Send emails from command line

SYNOPSIS

ssmtp [options] [recipients...]
ssmtp [options] -t

PARAMETERS

-t
    Read recipients from the message header (To:, Cc:, Bcc: fields). This is often the default or preferred method when piping mail to ssmtp.

-v
    Enable verbose output. Displays communication with the SMTP server, which is useful for debugging connection or authentication issues.

-s subject
    Set the subject of the email. Note: It's generally preferred and more robust to include the 'Subject:' header directly in the email content piped to ssmtp's standard input.

-C config_file
    Specify an alternate configuration file instead of the default /etc/ssmtp/ssmtp.conf.

-q
    Attempt to send messages from the queue. While ssmtp is not designed as a full-featured queuing MTA, this option exists for limited queuing scenarios or compatibility.

-a auth_file
    Specify a file containing authentication details. Typically, authentication is configured directly in ssmtp.conf.

recipients...
    One or more email addresses to send the mail to. If -t is used, these recipients are ignored.

DESCRIPTION

ssmtp is a minimalist Mail Transfer Agent (MTA) designed to forward email from a local system to a configured remote mail server (SMTP relay). It acts as a sendmail-compatible wrapper, allowing applications and scripts to send outbound emails without the overhead of a full-fledged MTA like Postfix or Sendmail.

It's particularly useful for systems that only need to send outgoing mail, such as servers sending system alerts, cron job output, or application notifications. ssmtp reads the email content from standard input, typically including headers like 'To:', 'From:', and 'Subject:', and then transmits it via the specified SMTP server using credentials defined in its configuration file. Its simplicity makes it ideal for small footprints and environments where maintaining local mail queues or receiving incoming mail is not required.

CAVEATS

ssmtp is a lightweight forwarder, not a full Mail Transfer Agent. It lacks features like local mailboxes, robust mail queuing, and incoming mail processing.

Configuration files (/etc/ssmtp/ssmtp.conf) often contain sensitive authentication credentials (username/password) in plain text. It is critical to ensure strict file permissions (e.g., 0640 or 0600) to protect these credentials.

Its development has largely stalled, and it is often considered unmaintained. For new deployments or more robust features, alternatives like msmtp are generally recommended.

CONFIGURATION FILES

The primary configuration file for ssmtp is /etc/ssmtp/ssmtp.conf. This file defines the SMTP relay host, authentication credentials, and default sender information. Another related file is /etc/ssmtp/revaliases, which allows mapping local usernames to specific external email addresses for sending.

EMAIL CONTENT FORMAT

ssmtp expects email content, including headers (e.g., 'From:', 'To:', 'Subject:') and body, to be provided via standard input in RFC 822/2822 compliant format.

HISTORY

ssmtp was developed to provide a simpler, more resource-efficient alternative to traditional, complex Mail Transfer Agents like Sendmail. Its primary goal was to enable Unix-like systems to send outbound email through an external SMTP server without needing a full local mail infrastructure. It gained popularity for its small footprint and ease of configuration, making it suitable for embedded systems, virtual machines, and servers dedicated to specific tasks that only required outbound email capabilities.

While once widely used, its development has largely ceased, and more modern alternatives like msmtp have emerged, offering better security features (e.g., GnuPG support), multiple account configurations, and more active maintenance.

SEE ALSO

mailx(1), msmtp(1), sendmail(8), postfix(8), exim(8)

Copied to clipboard