>_SMTPBoxDOCUMENTATION

Configure Nodemailer SMTP email testing

Send a Node.js test email with Nodemailer, require STARTTLS and troubleshoot SMTP authentication and timeouts.

Install and configure Nodemailer

Use Node.js with npm install nodemailer. Set SMTPBOX_SMTP_USER and SMTPBOX_SMTP_PASSWORD to an inbox's SMTP credential in the server environment. Save this as send-test.mjs.

import nodemailer from 'nodemailer';

const { SMTPBOX_SMTP_USER: user, SMTPBOX_SMTP_PASSWORD: pass } = process.env;
if (!user || !pass) throw new Error('Set the inbox SMTP credentials');
const transport = nodemailer.createTransport({
  host: 'smtp.smtpbox.dev',
  port: 587,
  secure: false,
  requireTLS: true,
  auth: { user, pass },
  connectionTimeout: 10000,
  greetingTimeout: 10000,
  socketTimeout: 30000,
});
await transport.verify();
await transport.sendMail({
  from: 'Example app <hello@example.test>',
  to: 'qa@example.test',
  subject: 'Nodemailer SMTPBox test',
  text: 'Your SMTP connection works.',
  html: '<p>Your SMTP connection works.</p>',
});
console.log('Test message accepted by the sandbox');

Send and inspect

Run node send-test.mjs and open the selected inbox in SMTPBox. Check both text and HTML views. verify() checks the connection and authentication; only sendMail() sends a message.

Match the port to TLS

Ports 587 and 2525 start with SMTP and upgrade using STARTTLS, so use secure: false with requireTLS: true. For port 465, set secure: true for TLS from the start. Leave certificate verification enabled. See the official Nodemailer SMTP transport documentation.

Automate content checks

Use a unique full recipient for each test, trigger your application and call the REST wait endpoint. API keys are independent of SMTP credentials. The Playwright email testing example waits for processing and validates the application link before navigation.

Troubleshooting

Authentication failures usually indicate the wrong inbox credential. A connection timeout can indicate a blocked outbound port. If SMTP succeeds but the message is absent, check the selected inbox and workspace allowance. Keep all credentials on the server; browser code must never contain SMTP passwords.

Updated