Terminal Email

msmtp

CLIMail tool

SMTP client with a sendmail-compatible interface that terminal mail clients use to send mail.

msmtp takes a message on standard input and hands it to an SMTP server. Its command line options and exit codes match sendmail, so clients such as NeoMutt, sup, mu4e and git send-email can call it in place of /usr/sbin/sendmail. It supports several accounts, TLS, many authentication methods and reading the password from a command. The bundled msmtpq script queues mail while offline.

Type
Mail tool
Interface
Command-line tools and prompts
Systems
Runs on Linux, macOS, Windows and BSD, on Android through Termux.
Language
C
License
GPL 3.0 or later
Latest version
1.8.34
Maintained
Yes
Website
marlam.de
Source
git.marlam.de/gitweb/?p=msmtp.git
Documentation
marlam.de

Install

SystemSupportInstall
LinuxNative
aptsudo apt install msmtp
dnfsudo dnf install msmtp
pacmansudo pacman -S msmtp
apksudo apk add msmtp
macOSNative
Homebrewbrew install msmtp
WindowsNative
MSYS2pacman -S mingw-w64-ucrt-x86_64-msmtp
Cygwinsetup-x86_64.exe -q -P msmtp

Native builds through MSYS2 and Cygwin.

BSDNative
FreeBSD pkgpkg install msmtp
OpenBSDpkg_add msmtp
AndroidThrough Termux
Termuxpkg install msmtp

Protocols and features

Protocols
Protocolmsmtp
IMAPNo
POP3No
SMTPYes
JMAPNo
MaildirNo
mboxNo
notmuchNo
Features
Featuremsmtp
OpenPGPNo
S/MIMENo
OAuth2 sign-invia passwordeval with a token command (oauthbearer, xoauth2)
ThreadsNo
SearchNo
HTML mailNo
MouseNo
Multiple accountsYes
Offline usequeues mail with the bundled msmtpq script
CalendarNo
ContactsNo
Vim-style keysNo
Configuration~/.msmtprc or ~/.config/msmtp/config text file

Pros and cons

Pros

  • Drop-in sendmail replacement that most terminal clients can call
  • passwordeval reads the password from pass, gpg or a keyring
  • Small, with packages on every major platform including Windows and Termux

Cons

  • Send only; needs a separate tool or client to read mail
  • Offline queueing needs the separate msmtpq script
  • OAuth2 tokens must be fetched and refreshed by an external program

Use msmtp with Forward Email

How msmtp fits with a Forward Email mailbox. Replace you@example.com with your alias and the password command with your own. The same settings work with any provider once the server names change.

~/.msmtprc
defaults
auth           on
tls            on
# Debian/Ubuntu path; omit this line to use the system default trust store
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        ~/.msmtp.log

account        forwardemail
host           smtp.forwardemail.net
port           465
tls_starttls   off
from           you@example.com
user           you@example.com
passwordeval   pass show forwardemail/you@example.com

account default : forwardemail

# Test: printf 'Subject: test\n\nhello\n' | msmtp you@example.com
ProtocolServerPortSecurity
IMAPimap.forwardemail.net993SSL/TLS
POP3pop3.forwardemail.net995SSL/TLS
SMTPsmtp.forwardemail.net465SSL/TLS
SMTPsmtp.forwardemail.net587STARTTLS

Username: your full alias address, such as you@example.com. Password: the one shown by Generate Password next to the alias in your Forward Email account. Folders: INBOX, Drafts, Sent Mail, Trash, Spam and Archive.

Prefer no config at all? Forward Email's terminal app signs in with your account and has mail, calendar and contacts in one program.

Questions

Does msmtp work on Windows?

Yes, it runs natively on Windows. Native builds through MSYS2 and Cygwin.

Does msmtp support IMAP?

No. msmtp does not use IMAP.

Is msmtp open source?

Yes, under the GPL 3.0 or later.

How do I use msmtp with Forward Email?

Use the config in the Forward Email section on this page, saved as ~/.msmtprc, and replace the address and password with your own.

Sources