Postfix
Relay a whole machine's outgoing mail into a sandbox — every application on it, without touching any of them.
1Point the relay at the sandbox
# /etc/postfix/main.cf relayhost = [smtp.mailclutch.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_security_level = encrypt
The square brackets matter: they tell Postfix not to look up MX records for the host.
2Store the credentials
# /etc/postfix/sasl_passwd [smtp.mailclutch.com]:587 mc_0000000000000000:pw_0000000000000000
sudo postmap /etc/postfix/sasl_passwd sudo chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db sudo systemctl reload postfix
The host and port in sasl_passwd must match relayhost character for character, brackets included, or the lookup misses and Postfix sends unauthenticated.
3Send a test message
echo "Hello from Postfix." | mail -s "Sandbox check" anyone@example.comtail -f /var/log/mail.log shows the delivery, and the sandbox shows the message.
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
SASL support has to be built in
postconf -amust listcyrusordovecot. On Debian and Ubuntu that means thelibsasl2-modulespackage.Mail already in the queue
Messages queued before the change keep their old destination until you run
postqueue -f.
Other stacks
The same four values in another dialect. Every guide below is filled in with the sandbox pair at the top of this page.
Frameworks and languages
- LaravelFive .env variables, no package
- SymfonyOne MAILER_DSN
- DjangoFive settings, nothing installed
- RailsAction Mailer smtp_settings
- Node.jsA Nodemailer transport
- Next.jsRoute Handler or Server Action
- Gonet/smtp, standard library
- SpringFive Spring Boot properties
- JavaJakarta Mail, no framework
- .NETMailKit: connect, auth, send
- PHPPHPMailer, no framework
- Pythonsmtplib, standard library
- Rustlettre over a STARTTLS relay