msmtp
Send emails via SMTP
TLDR
Send an email using the default account configured in ~/.msmtprc
Send an email using a specific account configured in ~/.msmtprc
Send an email without a configured account. The password should be specified in the ~/.msmtprc file
SYNOPSIS
msmtp [options] [--]
PARAMETERS
-a
Specifies the account to use from the configuration file. Defaults to the default account.
-t
Reads recipients from the To:, Cc:, and Bcc: headers of the message.
-c
Specifies the configuration file to use. Defaults to ~/.msmtprc or /etc/msmtprc.
-d
Enables debugging mode, providing verbose output.
-v
Enables verbose mode, providing additional information during operation.
-f
Sets the sender address for the email.
-C
Add a custom header to the email.
-s
Enables STARTTLS encryption.
-S
Enables TLS encryption. Same as -s but deprecated.
-q
Quiet mode, suppresses most output.
--logfile
Specifies the log file to use.
--serverinfo
Prints server information and capabilities.
DESCRIPTION
msmtp is a versatile SMTP (Simple Mail Transfer Protocol) client that allows users to send emails from the command line, scripts, or applications. Unlike more complex Mail Transfer Agents (MTAs) like Sendmail or Postfix, msmtp focuses on simplicity and ease of configuration, making it ideal for situations where a full-fledged MTA is not required.
It's particularly useful for sending system notifications, automated reports, or emails from cron jobs. msmtp supports various authentication methods including TLS and STARTTLS for secure email transmission. The configuration is typically handled through a configuration file (usually ~/.msmtprc or /etc/msmtprc) where you can define one or more accounts, each with its own SMTP server settings, authentication details, and other options.
msmtp is designed to be a Mail Submission Agent (MSA), meaning it primarily focuses on submitting mail to a designated mail server rather than handling local mail delivery or complex routing. This focus on a single task keeps it lightweight and easy to manage.
CAVEATS
msmtp primarily focuses on sending emails and lacks the full functionality of a complete MTA. It relies on a properly configured SMTP server to handle the actual delivery of emails. Improper configuration can lead to authentication failures or other delivery issues.
CONFIGURATION FILE FORMAT
The configuration file (usually ~/.msmtprc) uses a simple, section-based format. Each account is defined within square brackets (e.g., [default], [myaccount]). Within each section, you specify settings like host, port, from, auth, user, password, tls, tls_trust_file, etc. The file should be readable only by the user for security reasons (chmod 600 ~/.msmtprc).
AUTHENTICATION METHODS
msmtp supports various authentication methods, including PLAIN, LOGIN, CRAM-MD5, and DIGEST-MD5. The 'auth' option in the configuration file specifies the desired method. Ensure that the chosen method is supported by your SMTP server.
TLS AND STARTTLS
For secure email transmission, msmtp supports TLS and STARTTLS encryption. TLS encrypts the entire session from the beginning, while STARTTLS upgrades an unencrypted connection to a secure one. Use the 'tls' and 'tls_trust_file' options in the configuration file to configure TLS/STARTTLS.
HISTORY
msmtp was developed as a lightweight alternative to larger, more complex MTAs. It has gained popularity for its simplicity and ease of configuration, particularly in environments where a minimal email sending capability is required. Development continues with updates and bug fixes to ensure compatibility with modern SMTP protocols and security standards.