Deploy Mailpit

Catch test emails over SMTP and inspect them in a web UI and REST API.

Deploy Mailpit

Just deployed

/data

Deploy and Host Mailpit on Railway

Mailpit logo

Mailpit is an open source email testing tool. It runs a fake SMTP server that accepts every message your app sends and shows it in a web inbox instead of delivering it, so you can check sign-up emails, password resets and newsletters without spamming real people. It adds an HTML compatibility checker, a link checker, a REST API for automated tests, tagging, webhooks and SMTP relay for releasing chosen messages. It is MIT licensed with about 10,900 GitHub stars, and v1.33.1 shipped in November 2026. It is the actively maintained successor to MailHog. This template runs it on Railway with a volume for the message store, a generated password on the web UI and API, and required SMTP credentials so only your services can send to it. Mailtrap's paid Email Sandbox plans start around $17/month. Mailpit on Railway costs about $5/month.


What This Template Deploys

ServicePurpose
mailpitaxllent/mailpit:latest, the official image. Web UI, REST API and Prometheus metrics on port 8025 with a public domain. SMTP on port 1025 over Railway's private network. Health check on /readyz.
Persistent VolumeMounted at /data. Holds the SQLite database mailpit.db with every captured message, attachment and tag, so your inbox survives redeploys.

About Hosting Mailpit

Every app that sends email needs a safe place to send it during development, staging and CI. Pointing staging at a real mail provider risks emailing customers, and reading raw SMTP logs is painful. Mailpit gives each environment a shared inbox that looks like a real mail client.

A full inbox UI. View formatted HTML, the highlighted HTML source, plain text, headers, the raw message and attachments. New mail appears instantly over web sockets, with optional browser notifications. Toggle mobile and tablet previews to see responsive layouts.

HTML check. Mailpit scores your HTML and CSS against the support tables of popular mail clients, and lists which features will break in Outlook, Gmail or Apple Mail.

Link check. Test every link and linked image in a message and see which ones return errors.

Search and tags. Search by sender, recipient, subject, content or date. Tag messages by hand, with filters, or automatically through plus addressing such as test+signup@example.com.

REST API. List, search, read, tag and delete messages from code. End-to-end tests can trigger a password reset, fetch the email over the API, and follow the link inside.

Release and relay. Configure an upstream SMTP server and release a captured message to a real address, with an allowlist of accepted recipients for safety.

Chaos testing. Make the SMTP server return errors on purpose to test how your app handles failures and retries.

Webhooks. Post a JSON notification to your own URL for every received message.


Deploy Mailpit in Under 5 Minutes

  1. Click Deploy on Railway. Both passwords are generated for you.
  2. Wait for the /readyz health check to pass.
  3. Open the service's Variables tab. MP_UI_AUTH holds the web login as admin:password, and MP_SMTP_AUTH holds the SMTP login as mailpit:password.
  4. Open the public domain and sign in with the MP_UI_AUTH username and password.
  5. In your app's service, set the SMTP host to mailpit.railway.internal, port 1025, with the MP_SMTP_AUTH credentials and no TLS. Send a test email and watch it arrive.

Common Use Cases

  • Staging environments: catch every email from a staging app so no real user receives test mail.
  • Pull request previews: give Railway PR environments a safe SMTP target.
  • End-to-end tests: assert on sign-up, magic link and reset emails through the REST API in Playwright or Cypress.
  • Template design: preview HTML emails, check client compatibility and fix broken links before launch.
  • Shared QA inbox: let designers and testers see emails from every environment in one place.
  • Final client checks: release chosen messages through the relay to real Gmail and Outlook test accounts before a launch.
  • Background jobs: confirm queued digests and reminders actually go out, with timestamps for each send.
  • Load checks: Mailpit can ingest hundreds of messages per second, enough to test bulk sends.

Configuration

VariableRequiredDefaultDescription
MP_UI_AUTH🔐 Auto-generatedadmin: plus a 32-char secretBasic auth for the web UI, REST API and metrics
MP_SMTP_AUTH🔐 Auto-generatedmailpit: plus a 32-char secretCredentials every SMTP client must send
MP_SMTP_AUTH_ALLOW_INSECUREOptionaltrueAllows SMTP login without TLS on the private network
MP_DATABASEOptional/data/mailpit.dbSQLite message store on the volume
MP_MAX_MESSAGESOptional5000Messages kept before the oldest are pruned
MP_ENABLE_PROMETHEUSOptionaltrueServes /metrics behind the UI password
PORTAuto-set8025Web UI and API port
RAILWAY_DEPLOYMENT_DRAINING_SECONDSOptional10Shutdown window so SQLite closes cleanly

The SMTP gotcha. SMTP is not exposed publicly, only on mailpit.railway.internal:1025. Apps in the same Railway project can reach it; your laptop cannot. To send from outside Railway, add a TCP proxy on port 1025 and enable TLS first, because MP_SMTP_AUTH_ALLOW_INSECURE sends the password in clear text.

Plain login, not TLS. Most frameworks need TLS turned off for this setup. In Laravel set MAIL_ENCRYPTION=null; in Django set EMAIL_USE_TLS=False; in Nodemailer use secure: false.

Testing through the API. In a test, call GET /api/v1/search?query=to:user@example.com with the UI basic auth to find the newest email, then GET /api/v1/message/ID for its HTML, text and links. DELETE /api/v1/messages clears the inbox between test runs so each test starts empty.

One inbox per environment. Railway copies this service into every environment and PR preview, so each one gets its own Mailpit with its own credentials, and staging mail never mixes with preview mail.

Releasing to real inboxes. To let QA forward a captured message to a real address, set MP_SMTP_RELAY_HOST, MP_SMTP_RELAY_PORT and the relay login variables, plus MP_SMTP_RELAY_ALLOWED_RECIPIENTS to limit who can receive it.

More history. Raise MP_MAX_MESSAGES, or set it to 0 to keep everything, and watch the volume size.


Mailpit vs. Alternatives

FeatureMailpit on RailwayMailtrap Email SandboxMailHogsmtp4dev
HostingSelf-hostedHosted SaaSSelf-hostedSelf-hosted
LicenseMITProprietaryMITBSD-3-Clause
Actively maintained✅✅❌✅
Runs inside your Railway project✅❌✅✅
REST API✅✅✅✅
Message limitsYour volumePlan quotasMemoryYour disk
PriceAbout $5/monthFrom about $17/monthFreeFree

Mailtrap adds spam scoring, team seats and a hosted dashboard, but every plan caps monthly test emails. MailHog has had no release for years. smtp4dev is a solid .NET option; Mailpit is a single small Go binary with a faster UI.


Dependencies for Mailpit Hosting

  • A Railway account.
  • An app in the same Railway project that sends email over SMTP, or a TCP proxy for outside senders.

Deployment Dependencies

Implementation Details

The image follows the latest tag, so a redeploy picks up new releases; the current one is v1.33.1. Messages live in SQLite on the volume, so stopping or redeploying the service keeps your inbox. The UI password also protects the REST API and /metrics, so pass the same basic auth from your tests and Prometheus. The health check uses /readyz, which stays open. Optional spam checks need a separate SpamAssassin or Rspamd service, which this template does not include.


Frequently Asked Questions

What is Mailpit? An MIT-licensed SMTP server and web inbox that captures outgoing email for testing instead of delivering it.

How much does it cost to host Mailpit? About $5/month on Railway for one small service and its volume.

What SMTP settings should my app use? Host mailpit.railway.internal, port 1025, TLS off, and the username and password from MP_SMTP_AUTH.

Is Mailpit a replacement for MailHog? Yes. It accepts the same SMTP traffic, is actively maintained, and adds HTML checks, tags and a newer API.

Can Mailpit send real email? Only if you configure SMTP relay and release a message on purpose. By default nothing leaves Mailpit.

How many emails does it keep? 5,000 by default, pruning the oldest first. Change MP_MAX_MESSAGES to keep more.


Why Deploy and Host Mailpit on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Mailpit on Railway, you get a private test inbox for every app in your project, without monthly email quotas or a risk of emailing real users.


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
52