Mailtrap Email Sandbox: SMTP settings and how to catch your app's test emails

Catch your app's test emails in a private inbox: the SMTP settings, where they go, and what to check before launch.

Some links on this page are affiliate links. If you sign up through one, Rigcheck may earn a commission at no cost to you. It doesn't change what this guide recommends. How we handle this.

Building password resets, sign-up confirmations or order receipts means sending a lot of test email. Send it through a real email service and it can reach real people: a customer on a copied database, a teammate's inbox, or an address someone typed as a joke. It also counts against your sending reputation.

A sandbox fixes that. Your app sends email exactly as it will in production, but the sandbox's SMTP server keeps every message in a private inbox instead of delivering it. You can read each one, check its HTML and spam score, and nothing ever leaves.

This guide sets up Mailtrap's Email Sandbox, which needs no domain and no DNS records. It takes about five minutes.

Sending real email from your domain too? A sandbox doesn't check your domain's SPF, DKIM and DMARC records. Rigcheck does, in a few seconds.

What the sandbox is, and isn't

Mailtrap has two separate products in one account:

Email SandboxEmail Sending
Where email goesA private inbox in Mailtrap. Never delivered.Real recipients.
Domain setupNone neededVerify your domain with DNS records
Use it forDevelopment, QA and stagingProduction

This guide is about the sandbox. For real sending, see SPF, DKIM and DMARC for Mailtrap.

Step 1: Create an account and open your sandbox

Mailtrap creates a sandbox for you called My Sandbox. To open it, go to Sandboxes in the left menu, then My Sandbox.

Step 2: Copy the SMTP settings

In your sandbox, open the Integration tab and choose SMTP. Mailtrap shows four values:

SettingValue
Hostsandbox.smtp.mailtrap.io
Port2525 (587, 465 and 25 also work)
UsernameUnique to your sandbox, shown on the Integration tab
PasswordUnique to your sandbox, shown on the Integration tab

Each sandbox has its own username and password. Copy them from Mailtrap rather than from any guide or forum post, including this one.

Under Code Samples on the same tab, Mailtrap has ready-made settings for common languages and frameworks with your credentials already filled in. Using one is the quickest way to get every option right for your framework.

Step 3: Put the settings in your app

Put the four values wherever your app reads its mail settings, usually environment variables for your development or staging environment. Common examples, with placeholders where your own username and password go:

Laravel (.env)

MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your-sandbox-username
MAIL_PASSWORD=your-sandbox-password

Django (settings.py)

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "sandbox.smtp.mailtrap.io"
EMAIL_PORT = 2525
EMAIL_HOST_USER = "your-sandbox-username"
EMAIL_HOST_PASSWORD = "your-sandbox-password"

Node.js (Nodemailer)

const transporter = nodemailer.createTransport({
  host: "sandbox.smtp.mailtrap.io",
  port: 2525,
  auth: { user: "your-sandbox-username", pass: "your-sandbox-password" },
});

Keep the username and password out of your code repository: read them from environment variables or your framework's secrets file. Anyone with them can fill your sandbox.

Step 4: Send a test email

Trigger an email the normal way: request a password reset, sign up a test user, place a test order. The message appears in your sandbox within a few seconds, whatever address it was sent to.

Open it and check:

  • The content: names, links and amounts filled in correctly, no leftover template placeholders.
  • The HTML check (HTML Check tab): which parts of your HTML and CSS some email programs don't support, and roughly what share of readers' email programs can show your email properly.
  • The spam report (Spam Analysis tab): a SpamAssassin score, where Mailtrap counts under 5 as good, and whether your sending IP address or domain is on common blocklists.
  • The headers: the From, Reply-To and any Bcc addresses your app added.

If emails don't arrive

As of November 2026, Mailtrap's free plan covers up to 50 test emails a month, with one sandbox that keeps the latest 10 messages. Automated test suites can go through that quickly, so check the limits on Mailtrap's pricing page if you plan to run tests on every change.

Moving to real sending

When you're ready for real recipients, don't just remove the sandbox settings. Production needs its own setup:

  1. Verify your sending domain in Mailtrap Email Sending and add its DNS records. SPF, DKIM and DMARC for Mailtrap walks through it.
  2. Swap the SMTP settings in production only for the ones on your sending domain's Integration tab. Keep the sandbox settings in development and staging so test email stays trapped there.
  3. Check your domain with Rigcheck to confirm SPF, DKIM and DMARC pass.

Check your sending domain. Before real email goes out, Rigcheck confirms SPF, DKIM and DMARC are in place.

Check my setup

Browse all guides