Mail previews
Every email your app sends with nodemailer, in the local dashboard: its HTML as a phone or a desktop shows it, its text, who it went to, and the request that sent it.
Every email your app sends with nodemailer shows up on the local dashboard's Mail page as it was sent: its HTML as a phone or a desktop shows it, its text, who it went to, and how the server answered. Each one is linked to the request or job run that sent it, and to the line of your code that called sendMail().
There's nothing to set up: PeekInside finds nodemailer in your project, and transporters made before PeekInside started are covered too.
const transporter = nodemailer.createTransport({ host: 'smtp.example.com', port: 587, auth });
app.post('/signup', async (req, res) => {
const user = await createUser(req.body);
await transporter.sendMail({ to: user.email, subject: 'Welcome to Acme', html: renderWelcome(user) });
res.status(201).json(user);
});
Nothing about how emails are sent changes: they go out through your transport as before. To look at emails without sending them while you develop, use nodemailer's own jsonTransport (or streamTransport): the Mail page shows them just the same.
What you see#
- The message as your transport got it, after nodemailer's plugins ran: an email rendered by a template plugin (
nodemailer-express-handlebars,@nestjs-modules/mailer) is shown rendered, with the transporter's defaults (a defaultfrom) applied. - The HTML in a frame, as wide as a desktop window or a phone, white like a mail client. Remote images stay off until you load them, so a tracking pixel doesn't count an open, and scripts never run. Links open in a new tab.
- The text, the HTML source, and the details: the headers your app set, the attachments by name, type and size, the message id, the envelope, and the server's answer, with the recipients it accepted and rejected.
- An email that wasn't sent, marked in the list, with the error your transport gave (
ECONNECTION,EAUTH, a rejected recipient).
| Place | What it shows |
|---|---|
| Mail page | Every email, live, newest first. Filter by subject, address or file; status:failed keeps the ones that weren't sent, request:<id> and job:<id> one request's or job run's |
| A request's Overview | The emails it sent, linking to the Mail page |
| A request's Timeline | Each email, from the sendMail() call to the server's answer, next to the request's queries and calls |
What's kept#
- Bodies are kept as text, up to 256 KB of HTML and 64 KB of text. A body given as a file, a URL or a stream is named, but not read.
- Attachments are listed by name, type and size: their content is never recorded. So images attached inline (
cid:) don't show in the preview. - The local hub keeps the newest 500 emails of each project. At most 20 emails a second are recorded per process (bursts of 100). Clear them from the Mail page.
Only on your machine#
Mail previews are for development. They go to the local dashboard only, never to PeekInside Cloud. Turn them off with captureMail: false.
nodemailer 6 and later are supported, whether your app requires it or imports it. When your app's nodemailer isn't in the project's own node_modules (a monorepo package with its own copy, a bundled app), hand it over:
import nodemailer from 'nodemailer';
PeekInside.attach(app).instrument(nodemailer);
Mail previews need PeekInside 1.4 or later.