Agentic hosting is here. Connect to our MCP now
CloudLinux.ro
Dev environments

Test your application's email with smtp4dev

Updated 11/29/2026

Every application sends email: account confirmations, password resets, invoices, notifications. When you test them on a development or staging environment, the last thing you want is a real customer receiving a test email. smtp4dev solves that: it is an SMTP server that accepts everything, delivers nothing and shows you each message in a web inbox.

1. Install smtp4dev

Order a cloud server with the smtp4dev app (1 GB of RAM is enough). When it is done, /root/app-credentials.txt holds the username and password, the same for the web inbox, SMTP and IMAP. The inbox opens at the server's address, over HTTPS. To install it yourself, the steps are in how to install smtp4dev.

The SMTP settings for your applications:

  • Host: the smtp4dev server's address (SERVER_ADDRESS in the examples below)
  • Port: 2525
  • Encryption: none (no TLS)
  • Authentication: PLAIN or LOGIN, with the username and password from the file

The server only accepts that user, so nobody else can use it as a spam relay.

2. Laravel

In the test environment's .env file:

MAIL_MAILER=smtp
MAIL_HOST=SERVER_ADDRESS
MAIL_PORT=2525
MAIL_USERNAME=dev
MAIL_PASSWORD=PASSWORD
MAIL_SCHEME=smtp
[email protected]

On Laravel versions before 11, use MAIL_ENCRYPTION=null instead of MAIL_SCHEME. Then run php artisan config:clear and send a test email from the app, a password reset for example.

3. WordPress

Install an SMTP plugin (WP Mail SMTP, for example), pick "Other SMTP" and fill in the host, port 2525, encryption "None", turn "Auto TLS" off and turn authentication on with the username and password from the file. The plugin can send a test email straight away.

4. Node.js

import nodemailer from 'nodemailer';

const transport = nodemailer.createTransport({
  host: 'SERVER_ADDRESS',
  port: 2525,
  secure: false,
  auth: { user: 'dev', pass: 'PASSWORD' },
});

await transport.sendMail({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Test',
  html: '

Hello!

', });

5. Python

import smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Subject'] = 'Test'
msg.set_content('Hello!')

with smtplib.SMTP('SERVER_ADDRESS', 2525) as smtp:
    smtp.login('dev', 'PASSWORD')
    smtp.send_message(msg)

6. What the web inbox shows

Each message appears right away with everything the app sent: the HTML and text parts, the raw source, the headers, the recipients and the attachments. smtp4dev also checks the message HTML and flags markup that renders badly in some email clients. The sessions tab shows the full SMTP conversation, which helps when your app gets an error and you don't know why. The last 1000 messages are kept.

7. Read the messages over IMAP

IMAP is not exposed to the internet. You use it through an SSH tunnel from your computer:

ssh -L 1143:127.0.0.1:1143 root@SERVER_ADDRESS

Then set up an IMAP account in Thunderbird or in your tests on localhost, port 1143, no encryption, with the same username and password.

8. In automated tests and CI

You can send a sample email straight from the terminal, for example with swaks:

swaks --to [email protected] --server SERVER_ADDRESS:2525 \
  --auth LOGIN --auth-user dev --auth-password PASSWORD

The inbox also has an API (documented in the smtp4dev project) that your tests can query to check that an email went out, with the right subject and recipient. That way your email flows are checked on every run of your CI/CD pipeline.

Good practice

  • Test data only: SMTP on port 2525 is not encrypted, so the password and the messages travel in the clear. Never send real customer data through it.
  • One smtp4dev for every environment: the same server can serve development and your staging environment. In production the app sends through your mail server or an SMTP relay.
  • Hourly billing: if you only need it for one project, delete it at the end and pay only for the hours used.

See also how to send email from your app in production and the smtp4dev, Mailpit and MailHog comparison.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials