Node.js
A Nodemailer transport pointed at a sandbox, and every sendMail lands there.
Prerequisites
- Node.js 18 or later
1Install Nodemailer
npm install nodemailer2Create the transport
import nodemailer from 'nodemailer'; export const mailer = nodemailer.createTransport({ host: 'smtp.mailclutch.com', port: 587, secure: false, // STARTTLS is negotiated after connecting auth: { user: 'mc_0000000000000000', pass: 'pw_0000000000000000', }, });
secure: false on port 587 is not a downgrade: the connection starts in the clear and is upgraded by STARTTLS. secure: true belongs to port 465.
3Send a test message
await mailer.sendMail({ from: 'staging@example.com', to: 'anyone@example.com', subject: 'Sandbox check', html: '<h1>Hello from Node.js</h1>', });
await mailer.verify() checks the connection and the credentials without sending anything.
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 sandbox with an account and it stays.
Awaiting your email
Send from any address; it stops here rather than going onward. The sandbox keeps what it catches for 24 hours.
Go further
Unawaited sendMail
In a short script, await
sendMail— an unawaited promise dies with the process and the message never goes out.Connection timeout
A timeout rather than an error usually means port 587 is blocked on your network. Switch
portto 2525, or to 465 withsecure: true.
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
- 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