msmtp

A sendmail-compatible relay for cron jobs, scripts and anything that shells out to sendmail.

1Write the account file

~/.msmtprc
# ~/.msmtprc
account        sandbox
host           smtp.mailclutch.com
port           587
auth           on
user           mc_0000000000000000
password       pw_0000000000000000
from           staging@example.com
tls            on
tls_starttls   on

account default : sandbox

msmtp refuses to run if the file is readable by anyone else — chmod 600 ~/.msmtprc.

2Send a test message

printf 'Subject: Sandbox check\n\nHello from msmtp.\n' | msmtp anyone@example.com

Watch it land

Open the sandbox and the message is there — rendered HTML, plain text, raw source, attachments, and the SPF, DKIM and DMARC verdicts. It updates live, so you can leave it open next to your terminal.

Nothing is ever delivered onward, whatever address you send to; claim the inbox with an account and it stays.

Awaiting your email

Send from any address; it stops here rather than going onward. The inbox keeps what it catches for 24 hours.

What usually goes wrong

  • As a sendmail drop-in

    Point anything that expects /usr/sbin/sendmail at msmtp -t; PHP's sendmail_path and mutt's sendmail both take it.

  • Debugging

    msmtp --serverinfo --host smtp.mailclutch.com --port 587 --tls checks the connection and prints what the server advertises, without sending.

Official documentationmsmtp (opens in a new tab)