# 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 (GPL-3.0-or-later)
- Latest version: 1.8.34
- Maintained: yes
- Website: https://marlam.de/msmtp/
- Source: https://git.marlam.de/gitweb/?p=msmtp.git
- Documentation: https://marlam.de/msmtp/msmtp.html

## Install

### Linux

Native.

- apt: `sudo apt install msmtp`
- dnf: `sudo dnf install msmtp`
- pacman: `sudo pacman -S msmtp`
- apk: `sudo apk add msmtp`

### macOS

Native.

- Homebrew: `brew install msmtp`

### Windows

Native. Native builds through MSYS2 and Cygwin.

- MSYS2: `pacman -S mingw-w64-ucrt-x86_64-msmtp`
- Cygwin: `setup-x86_64.exe -q -P msmtp`

### BSD

Native.

- FreeBSD pkg: `pkg install msmtp`
- OpenBSD: `pkg_add msmtp`

### Android

Through Termux.

- Termux: `pkg install msmtp`

## Protocols

- IMAP: No
- POP3: No
- SMTP: Yes
- JMAP: No
- Maildir: No
- mbox: No
- notmuch: No

## Features

- 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

- 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

File: `~/.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
```

| 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. Password: the one from Generate Password next to the alias. Folders: INBOX, Drafts, Sent Mail, Trash, Spam and Archive.

## 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

- https://marlam.de/msmtp/
- https://marlam.de/msmtp/download/
- https://marlam.de/msmtp/msmtp.html
- https://github.com/marlam/msmtp
- https://github.com/marlam/msmtp/blob/master/doc/msmtp.texi
- https://github.com/marlam/msmtp/tree/master/scripts/msmtpq
- https://packages.debian.org/search?keywords=msmtp&searchon=names&exact=1
- https://mdapi.fedoraproject.org/rawhide/pkg/msmtp
- https://archlinux.org/packages/extra/x86_64/msmtp/
- https://pkgs.alpinelinux.org/packages?name=msmtp
- https://formulae.brew.sh/formula/msmtp
- https://packages.msys2.org/base/mingw-w64-msmtp
- https://cygwin.com/packages/summary/msmtp.html
- https://www.freshports.org/mail/msmtp/
- https://openports.pl/path/mail/msmtp
- https://github.com/termux/termux-packages/tree/master/packages/msmtp
