Node.js
A Nodemailer transport pointed at a sandbox, and every sendMail lands there.
Before you start
- 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 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
The process exits before the mail leaves
In a short script, await
sendMail— an unawaited promise dies with the process and the message never goes out.Keep the pair in the environment
Read
userandpassfromprocess.envin anything you commit. They are inlined here so the snippet runs as pasted.
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