Setting Up msmtp for Sending#
This tutorial sets up msmtp as an external mail sender for NeoMutt. You’ll install msmtp, write a configuration, send a test message, and connect it to NeoMutt.
NeoMutt has built-in SMTP support (see Set Up SMTP), but using an external tool like msmtp gives you logging, queuing, and per-account profiles independent of NeoMutt’s config. This is the approach used by tools like mutt-wizard.
Prerequisites#
A working mail account with SMTP access (server, port, username, and password).
msmtpinstalled on your system.NeoMutt installed.
On Fedora/RHEL:
sudo dnf install msmtp
On Debian/Ubuntu:
sudo apt install msmtp
On macOS:
brew install msmtp
Write the msmtp Configuration#
Create the file
~/.config/msmtp/config(or~/.msmtprc):
# Default settings applied to all accounts
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.config/msmtp/msmtp.log
# Account definition
account you@example.com
host smtp.example.com
port 465
tls_starttls off
from you@example.com
user you@example.com
passwordeval "pass you@example.com"
Replace the server, port, user, and password command with your values.
Understanding the Key Settings#
Setting |
Purpose |
|---|---|
|
Enable SMTP authentication |
|
Enable TLS encryption |
|
|
|
Path to system CA certificates (see the table below) |
|
Runs a command to retrieve your password |
|
Where msmtp writes delivery logs |
Port and TLS Combinations#
Port |
Protocol |
|
|---|---|---|
465 |
Implicit TLS |
|
587 |
STARTTLS |
|
Certificate File#
The tls_trust_file path varies by distribution:
Distribution |
Path |
|---|---|
Debian / Ubuntu |
|
Fedora / RHEL |
|
Arch Linux |
|
macOS (Homebrew) |
|
Password Retrieval#
For passwordeval, use any command that prints your password to stdout:
passwordeval "pass you@example.com"
passwordeval "gpg --batch -q --decrypt ~/.smtp-pass.gpg"
passwordeval "secret-tool lookup service smtp user you@example.com"
See Password Manager for more options.
Secure the Configuration File#
msmtp requires that its config file is not world-readable:
chmod 600 ~/.config/msmtp/config
Send a Test Message#
Send a test email from the command line:
echo "Test from msmtp" | msmtp you@example.com
Check the log file for confirmation:
cat ~/.config/msmtp/msmtp.log
Expected result: the log shows a successful delivery and the message arrives in your inbox.
If delivery fails, check the error in the log. Common problems are wrong port/TLS settings or an incorrect password command.
Connect msmtp to NeoMutt#
Add this line to your
neomuttrc:
set sendmail = "msmtp -a you@example.com"
The -a flag selects the msmtp account by name.
Compose and send a message in NeoMutt (press m).
Expected result: NeoMutt hands the message to msmtp for delivery.
Add a Second Account#
Append another account block to your msmtp config:
account work@company.com
host smtp.company.com
port 587
tls_starttls on
from work@company.com
user work@company.com
passwordeval "pass work@company.com"
Switch accounts in NeoMutt using a folder-hook:
folder-hook "work@company.com" "set sendmail='msmtp -a work@company.com'"
folder-hook "you@example.com" "set sendmail='msmtp -a you@example.com'"
Expected result: NeoMutt uses the right SMTP account for each mailbox.
See Managing Multiple Email Accounts for the complete multi-account setup.
Next Steps#
“I want to read mail offline too.” See Setting Up Offline Email with mbsync.
“I want to use NeoMutt’s built-in SMTP instead.” See Set Up SMTP.
“I want to secure my passwords.” See Password Manager.