Skip to content

Point your mailer at the sandbox

If your app can send through SMTP, it works with MailBench SMTP. Change the host, port, username and password, and every message lands in your inbox instead of being delivered.

Connection settings

Hostsmtp.example.com
Port 587STARTTLS (recommended)
Port 465Implicit TLS (SMTPS)
Port 2525STARTTLS, for networks that block 587
Username and passwordPer inbox. Copy them from the inbox's settings in the dashboard.
AuthenticationPLAIN or LOGIN

The examples below use your-inbox-user and your-inbox-pass. Replace them with your inbox's credentials, and keep them in environment variables, not in source control.

Laravel

Laravel reads SMTP settings from .env. Change these in your staging or CI environment.

.env

MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your-inbox-user
MAIL_PASSWORD=your-inbox-pass
MAIL_ENCRYPTION=tls

Next.js and Node.js (Nodemailer)

Create one transport and reuse it from route handlers, server actions or API routes. Keep the credentials in environment variables.

mailer.ts (Nodemailer, works in Next.js route handlers and server actions)

import nodemailer from 'nodemailer';

export const transport = nodemailer.createTransport({
  host: process.env.SMTP_HOST,      // smtp.example.com
  port: Number(process.env.SMTP_PORT ?? 587),
  secure: false,                    // STARTTLS on 587; use true with port 465
  auth: {
    user: process.env.SMTP_USER,    // your-inbox-user
    pass: process.env.SMTP_PASS,    // your-inbox-pass
  },
});

Ruby on Rails

Set Action Mailer to SMTP in the environment you want to capture, such as staging.

config/environments/staging.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: 'smtp.example.com',
  port: 587,
  user_name: ENV['SMTP_USER'],   # your-inbox-user
  password: ENV['SMTP_PASS'],    # your-inbox-pass
  authentication: :plain,
  enable_starttls_auto: true
}

Django

Use the SMTP backend and point it at your inbox.

settings.py

import os

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True  # STARTTLS
EMAIL_HOST_USER = os.environ['SMTP_USER']      # your-inbox-user
EMAIL_HOST_PASSWORD = os.environ['SMTP_PASS']  # your-inbox-pass

Any other SMTP client

Everything you need to configure a mailer that speaks SMTP.

Host:      smtp.example.com
Ports:     587 (STARTTLS), 465 (TLS), 2525 (STARTTLS, if 587 is blocked)
Username:  your-inbox-user
Password:  your-inbox-pass
Auth:      PLAIN or LOGIN

Send a test email with curl

No app needed. This sends one message over STARTTLS on port 587. It shows up in your inbox and is never delivered to the address in To.

cat > test-email.txt <<'MAIL'
From: App <noreply@app.test>
To: Sam <sam@example.org>
Subject: Hello from curl

This message is captured by the sandbox and never delivered.
MAIL

curl --url 'smtp://smtp.example.com:587' --ssl-reqd \
  --user 'your-inbox-user:your-inbox-pass' \
  --mail-from 'noreply@app.test' \
  --mail-rcpt 'sam@example.org' \
  --upload-file test-email.txt