msmtp

lightweight SMTP client for sending email from the command line

TLDR

Send email
$ echo "[message]" | msmtp [[email protected]]
Send email with subject
$ echo -e "Subject: [Hello]\n\n[Body]" | msmtp [[email protected]]
Send from specific account
$ msmtp -a [account_name] [[email protected]]
Test configuration
$ msmtp --serverinfo
Check account configuration
$ msmtp --configure [account_name]
Send file as message
$ msmtp [[email protected]] < [message.txt]
Print configuration
$ msmtp -P

SYNOPSIS

msmtp [-a account] [--serverinfo] [options] [recipients]

DESCRIPTION

msmtp is a lightweight SMTP client for sending email from the command line. It works as a sendmail replacement, enabling scripts and applications to send mail through external SMTP servers.Configuration in ~/.msmtprc defines accounts with server settings, authentication, and TLS options. Multiple accounts can be configured for different mail servers or identities.Password handling supports several methods: plaintext (not recommended), passwordeval to run a command (e.g., password manager), or system keyring integration.TLS is supported via STARTTLS or direct TLS connection. Certificate verification can be configured to use system CA certificates or specific files.As a sendmail replacement, msmtp can be symlinked to /usr/sbin/sendmail, making it the default mail transport for the system. Many applications use sendmail for outgoing mail.Integration with mutt, git, and other tools is straightforward - they just need to know the sendmail path or can use msmtp directly.

PARAMETERS

-a ACCOUNT, --account ACCOUNT

Use specified account.
-f ADDRESS, --from ADDRESS
Set From address.
-C FILE, --file FILE
Use configuration file.
--serverinfo
Print server information.
-P, --pretend
Print configuration, don't send.
--configure ACCOUNT
Show account configuration.
-d, --debug
Debug mode.
-t, --read-recipients
Read recipients from message.
-X FILE, --logfile FILE
Log to file.
--tls
Use TLS encryption.
--tls-starttls
Use STARTTLS.
--host HOST
SMTP server host.
--port PORT
SMTP server port.
--user USER
Authentication username.
--passwordeval CMD
Get password from command.

INSTALL

sudo apt install msmtp
sudo dnf install msmtp
sudo pacman -S msmtp
sudo apk add msmtp
sudo zypper install msmtp
brew install msmtp
nix profile install nixpkgs#msmtp

CAVEATS

Requires SMTP server access. Password storage needs consideration. Some providers require app-specific passwords. TLS certificate issues may occur. Queue/offline sending requires msmtpd or msmtp-queue.

HISTORY

msmtp was written by Martin Lambers starting around 2000 as a simple sendmail replacement. It focused on being lightweight and configurable, supporting modern SMTP with authentication and TLS. The project remains actively maintained.

SEE ALSO

sendmail(1), mutt(1), mailx(1)