msmtp
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
| System | Support | Install |
|---|---|---|
| Linux | Native | apt sudo apt install msmtpdnf sudo dnf install msmtppacman sudo pacman -S msmtpapk sudo apk add msmtp |
| macOS | Native | Homebrew brew install msmtp |
| Windows | Native | MSYS2 pacman -S mingw-w64-ucrt-x86_64-msmtpCygwin setup-x86_64.exe -q -P msmtpNative builds through MSYS2 and Cygwin. |
| BSD | Native | FreeBSD pkg pkg install msmtpOpenBSD pkg_add msmtp |
| Android | Through Termux | Termux pkg install msmtp |
Protocols and features
| Protocol | msmtp |
|---|---|
| IMAP | No |
| POP3 | No |
| SMTP | Yes |
| JMAP | No |
| Maildir | No |
| mbox | No |
| notmuch | No |
| Feature | msmtp |
|---|---|
| OpenPGP | No |
| S/MIME | No |
| OAuth2 sign-in | via passwordeval with a token command (oauthbearer, xoauth2) |
| Threads | No |
| Search | No |
| HTML mail | No |
| Mouse | No |
| Multiple accounts | Yes |
| Offline use | queues mail with the bundled msmtpq script |
| Calendar | No |
| Contacts | No |
| Vim-style keys | No |
| 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.
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| Protocol | Server | Port | Security |
|---|---|---|---|
| IMAP | imap.forwardemail.net | 993 | SSL/TLS |
| POP3 | pop3.forwardemail.net | 995 | SSL/TLS |
| SMTP | smtp.forwardemail.net | 465 | SSL/TLS |
| SMTP | smtp.forwardemail.net | 587 | STARTTLS |
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
- marlam.de/msmtp/
- marlam.de/msmtp/download/
- marlam.de/msmtp/msmtp.html
- github.com/marlam/msmtp
- github.com/marlam/msmtp/blob/master/doc/msmtp.texi
- github.com/marlam/msmtp/tree/master/scripts/msmtpq
- packages.debian.org/search?keywords=msmtp&searchon=names&exact=1
- mdapi.fedoraproject.org/rawhide/pkg/msmtp
- archlinux.org/packages/extra/x86_64/msmtp/
- pkgs.alpinelinux.org/packages?name=msmtp
- formulae.brew.sh/formula/msmtp
- packages.msys2.org/base/mingw-w64-msmtp
- cygwin.com/packages/summary/msmtp.html
- freshports.org/mail/msmtp/
- openports.pl/path/mail/msmtp
- github.com/termux/termux-packages/tree/master/packages/msmtp