MailHog vs Mailpit vs Alternatives: Email Testing Tools in 2027
MailHog still sits in thousands of docker-compose files, five years after its last release and now with an unpatched CVE. Here is how it compares with Mailpit and the other email testing tools, how to migrate in five minutes, and how to make emails part of your CI and your AI agent’s feedback loop.
Dmytro Vavreniuk
Product Engineer
Short version: replace MailHog with Mailpit. It uses the same ports, so for most projects the switch is one line in docker-compose, and you gain a real API, search, HTML, link and spam checks and security fixes that MailHog will never get. Pin the version, bind it to localhost, protect any shared instance, and update your tests from MailHog’s /api/v2 endpoints to Mailpit’s /api/v1. Choose smtp4dev if you are a .NET team or need IMAP, and a hosted sandbox such as Mailtrap if QA and product people need shared inboxes. New in 2026: MCP servers let your AI coding agent read the test inbox.
Our guide to testing your emails with MailHog still gets search traffic every week, which tells us how many teams still run it. That guide shows the workflow. This one answers the question we now get more often: should you still use MailHog in 2027, and if not, what instead?
What changed in 2026
| When | What happened |
|---|---|
| 13 Jan 2026 | MailHog gets a CVE: CVE-2022-50908, a stored cross-site scripting bug in MailHog 1.0.1 that lets an attacker inject scripts through an email attachment (CVSS 4.0 score 5.1, medium). MailHog’s last release was about five years ago, so no fix is coming. |
| 20 Jul 2026 | Two Mailpit CVEs are published: CVE-2026-45709 (server-side request forgery through the HTML check’s CSS fetcher, an incomplete fix of CVE-2026-23845) and CVE-2026-45712 (a race in the screenshot proxy that can crash the whole process). Both are fixed in Mailpit 1.30.0. |
| Sep - Oct 2026 | Mailpit keeps hardening: a new --allowed-hosts flag against DNS rebinding (1.31.1, 5 Sep), memory and MIME-part limits, and a fix for a malicious image that could loop the thumbnailer forever (1.32.0, 22 Oct, which also caps connections at 1,000). |
| 17 Nov 2026 | Mailpit 1.34.0 fixes GHSA-v887-64wg-qqc9, a crafted message that could crash the SMTP server, and removes deprecated flags: a relay config that still uses recipient-allowlist will stop Mailpit from starting until you rename it to allowed-recipients. |
| 2026 | Test inboxes get MCP servers. Community Mailpit MCP servers expose tools such as search_messages, check_html, check_spam or wait_for_message and extract_otp, and Mailtrap’s MCP server includes sandbox tools. Your coding agent can now read the email it just made your app send. |
Sources: MailHog CVEs, CVE-2026-45709, CVE-2026-45712, Mailpit releases and Mailpit 1.34.0, checked on 26 November 2026.
The lesson is not that Mailpit is insecure. It is the opposite: a mail catcher parses untrusted HTML, images and attachments and serves them in a browser, which makes it real attack surface. Mailpit gets advisories because it is maintained and audited, and fixes ship within days. MailHog has the same class of risk and nobody fixing it. A container you start with -p 8025:8025 on a laptop in a café or on a shared staging VM is reachable by more people than you think.
MailHog vs Mailpit side by side
| MailHog | Mailpit | |
|---|---|---|
| Status | No release for about five years; the Mailpit README calls it no longer maintained | Actively maintained, frequent releases (1.34.0 on 17 Nov 2026) |
| Known security issues | Stored XSS via attachments (CVE-2022-50908), unpatched | Several 2026 advisories, all fixed in current releases |
| Ports | SMTP 1025, web UI and API 8025 | SMTP 1025, web UI and API 8025 (same, so it is a drop-in swap) |
| Storage | In memory by default, optional MongoDB or Maildir | SQLite; in a temporary file by default or a persistent file you choose, auto-pruning (keeps 500 messages by default) |
| Search | Basic search by from, to or containing text | Full search syntax (to:, from:, subject:, tag:, is:unread and more) |
| Quality checks | None | HTML client compatibility check, link check, spam score via SpamAssassin, List-Unsubscribe validation |
| Failure testing | Jim, a chaos monkey for SMTP | Chaos feature with configurable SMTP errors |
| Release / relay | Release a message to a real SMTP server | Release with an allowed-recipients list, plus automatic forwarding |
| Extras | None | Tags (manual, filters, plus-addressing), webhooks, POP3, HTML screenshots, browser notifications, ARM64 images |
| API | /api/v1 and /api/v2 | /api/v1 REST API with OpenAPI documentation |
Mailpit started as a project inspired by MailHog, and it shows: the mental model, the ports and the “catch everything, show it in a web UI” workflow are the same. Everything around it is newer. The quality checks are the part teams underestimate. Knowing that a template uses CSS that Outlook ignores, or links to a staging URL, before a customer sees it is worth more than the UI.
Migrate from MailHog to Mailpit in five minutes
Because the ports are identical, your application config usually does not change at all. Swap the image, and take the chance to fix the defaults:
# docker-compose.yml - before
services:
mailhog:
image: mailhog/mailhog
ports: ["1025:1025", "8025:8025"]
# docker-compose.yml - after
services:
mailpit:
image: axllent/mailpit:v1.34.0 # pin a version, let Renovate/Dependabot bump it
ports:
- "127.0.0.1:1025:1025" # SMTP, bound to localhost only
- "127.0.0.1:8025:8025" # web UI + API
environment:
MP_DATABASE: /data/mailpit.db # keep messages across restarts (optional)
MP_MAX_MESSAGES: 5000 # auto-prune above this
MP_SMTP_AUTH_ACCEPT_ANY: 1 # app sends a user/password? accept anything
MP_SMTP_AUTH_ALLOW_INSECURE: 1 # ...even without TLS (local only!)
volumes:
- mailpit-data:/data
volumes:
mailpit-data:Three things to check after the swap. First, if your app sends SMTP credentials, Mailpit rejects them by default, while MailHog silently accepted them; the two MP_SMTP_AUTH_* variables restore the old behaviour for local use. Second, if you relay messages to a real server, use allowed-recipients: since 1.34.0 the old recipient-allowlist name stops Mailpit from starting. Third, any test code that talks to the MailHog API needs new endpoints:
| Task | MailHog | Mailpit |
|---|---|---|
| List messages | GET /api/v2/messages | GET /api/v1/messages |
| Find mail for a recipient | GET /api/v2/search?kind=to&[email protected] | GET /api/v1/search?query=to:[email protected] |
| Read one message | GET /api/v1/messages/{id} | GET /api/v1/message/{ID} (or /latest) |
| Delete everything | DELETE /api/v1/messages | DELETE /api/v1/messages |
| HTML / link / spam check | not available | GET /api/v1/message/{ID}/html-check, /link-check, /sa-check |
The response shapes differ too (Mailpit uses fields such as ID, Subject, Text and HTML), so wrap API calls in one small helper and migrate that instead of every test.
Make emails part of your end-to-end tests
The most common email bug is not a broken template. It is a flow that never sends the email, sends it to the wrong address or contains a link that points to the wrong environment. Those are only caught when the test follows the whole journey: fill the form, wait for the email, click the link. With Mailpit and Playwright that is about 30 lines:
// e2e/signup.spec.ts - the confirmation email is part of the test
import { test, expect, request } from '@playwright/test';
const MAILPIT = process.env.MAILPIT_URL ?? 'http://localhost:8025';
async function waitForEmail(to: string, timeoutMs = 15_000) {
const api = await request.newContext({ baseURL: MAILPIT });
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const res = await api.get('/api/v1/search', { params: { query: `to:"${to}"` } });
const { messages } = await res.json();
if (messages.length) {
const msg = await api.get(`/api/v1/message/${messages[0].ID}`);
return msg.json(); // { Subject, From, To, Text, HTML, ... }
}
await new Promise((r) => setTimeout(r, 500));
}
throw new Error(`No email for ${to} within ${timeoutMs} ms`);
}
test('signup sends a working confirmation link', async ({ page }) => {
const email = `user+${Date.now()}@example.test`; // unique per run and per worker
await page.goto('/signup');
await page.getByLabel('Email').fill(email);
await page.getByRole('button', { name: 'Create account' }).click();
const mail = await waitForEmail(email);
expect(mail.Subject).toContain('Confirm your email');
const url = mail.Text.match(/https?:\/\/\S+\/confirm\S*/)?.[0];
expect(url).toBeTruthy();
await page.goto(url!);
await expect(page.getByText('Email confirmed')).toBeVisible();
});The unique recipient is the important detail. With plus-addressing every test and every parallel worker gets its own address, so tests never read each other’s mail and you do not have to clear the inbox between them. In CI, run Mailpit as a service container:
# .github/workflows/e2e.yml (excerpt)
jobs:
e2e:
runs-on: ubuntu-latest
services:
mailpit:
image: axllent/mailpit:v1.34.0
ports: ["1025:1025", "8025:8025"]
env:
SMTP_HOST: localhost
SMTP_PORT: 1025
MAILPIT_URL: http://localhost:8025
steps:
- uses: actions/checkout@v4
- run: npm ci
- name: Wait for Mailpit
run: for i in $(seq 1 30); do curl -sf $MAILPIT_URL/api/v1/info && break; sleep 1; done
- run: npx playwright testThen add checks that a human would otherwise do by hand before a template release:
# Is this template going to break in Outlook or land in spam?
ID=latest
curl -s localhost:8025/api/v1/message/$ID/html-check | jq '.Total'
curl -s localhost:8025/api/v1/message/$ID/link-check | jq '.Errors'
# spam score needs a SpamAssassin server: mailpit --enable-spamassassin=spamassassin:783
curl -s localhost:8025/api/v1/message/$ID/sa-check | jq '{Score, IsSpam}'For failure paths, enable Mailpit’s chaos feature and make SMTP return errors on purpose. Your password-reset flow should show a useful message and log the failure when the mail server says no, not swallow it. If you build templates yourself, our guide on building a robust mail template system covers the template side, and once real domains send real mail, deliverability becomes the next problem to solve.
New in 2026: let your AI agent read the test inbox
Coding agents can now run your app, click through it with a browser tool and read logs. Until recently the email step was a blind spot: the agent changed the signup flow and had no way to see the email it produced. MCP servers for test inboxes close that gap. Community servers for Mailpit expose tools such as search_messages, get_message_html, check_html, check_links and check_spam, or task-shaped ones like wait_for_message and extract_otp. Mailtrap’s official MCP server covers its hosted sandbox.
// .mcp.json (Claude Code) or .cursor/mcp.json - community server, review it first
{
"mcpServers": {
"mailpit": {
"command": "mailpit-mcp-server",
"env": {
"MAILPIT_URL": "http://localhost:8025"
}
}
}
}
# install: go install github.com/amirhmoradi/mailpit-mcp/cmd/mailpit-mcp-server@latest
# prompt: "Register a user on localhost:3000, then read the confirmation email in
# Mailpit, run check_html and check_links on it and fix what fails."Two cautions. These Mailpit servers are community projects, not part of Mailpit itself, so read the code and pin a version before you install one. And give the agent read and check tools only: delete_messages, release_message and send_message are not needed to verify an email, and release can send mail to the outside world. The same evidence-first loop works for the rest of a bug, as we describe in AI agent debugging in production: the agent gets the test inbox from Mailpit and the user’s session, console errors and failed requests from the LogNroll MCP server.
The alternatives, compared
| Tool | Type | Best for | Note |
|---|---|---|---|
| Mailpit | Local, open source (Go) | The default for most teams: drop-in MailHog replacement, rich API, quality checks | Single binary or Docker image axllent/mailpit; ARM64 builds |
| smtp4dev | Local, open source (.NET, BSD-3) | .NET shops and anyone who wants IMAP access, multiple mailboxes and relay rules | Docker rnwood/smtp4dev, winget or dotnet tool; 3.15.0 is the current release |
| MailCrab | Local, open source (Rust) | A tiny, fast catcher with a clean UI and nothing else | Fewer features and a smaller API than Mailpit |
| MailDev | Local, open source (Node.js) | Node projects that already run it; can be embedded as a library | Slower release pace; check activity before adopting |
| MailHog | Local, open source (Go) | Nothing new. Keep it only until you migrate | Unmaintained, unpatched XSS |
| Mailtrap Email Sandbox | Hosted SaaS | Shared inboxes for QA and product, staging environments, spam and client-rendering reports | Free tier is small; has an MCP server with sandbox tools |
| Mailosaur | Hosted SaaS | End-to-end tests against real addresses, including SMS codes | Paid; strongest when tests run against deployed environments |
The big split is local versus hosted. Local catchers (Mailpit, smtp4dev, MailCrab, MailDev) cost nothing, need no account and keep test data on your machine, which matters when test emails contain real-looking personal data. Hosted sandboxes cost money but give QA, product and support people a shared inbox per environment without running Docker, and they can test against deployed staging environments without exposing a mail catcher to the internet.
Which one should you pick?
- Still on MailHog: switch to Mailpit now. It is the shortest migration with the biggest gain.
- Laptops and CI for most stacks: Mailpit, pinned and bound to localhost.
- .NET team, or you need IMAP, several mailboxes or relay rules: smtp4dev.
- You want the smallest possible container and nothing else: MailCrab.
- Non-developers need to see test emails, or you test against a shared staging environment: a hosted sandbox such as Mailtrap, or Mailosaur when tests need real addresses and SMS codes.
Security hygiene for mail catchers
Treat a mail catcher like a debug endpoint. On a laptop, bind it to 127.0.0.1. On a shared server, put it on a private network, turn on UI authentication and set --allowed-hosts so the API is not reachable through DNS rebinding. Never route production DNS or customer traffic to it, and never relay to real recipients without an allow-list limited to your own domain. Most importantly, pin the version and let your dependency bot update it: Mailpit shipped more than half a dozen security fixes in 2026 alone, and they only protect you if you pull them.
When the email works but users still get stuck
A green test proves the email is sent and the link works in your environment. It does not prove that real users get through. Confirmation links opened in a different browser, expired reset tokens, a magic link prefetched by a corporate mail scanner: these show up only in production. With session replay you see exactly what happened when a user opened the link, including the console error and the failed request behind it, and error tracking with session replay ties the failure to the session that hit it.
Email testing checklist
| Item | How to check |
|---|---|
| Nothing still runs MailHog | grep -r mailhog docker-compose*.yml .github/ helm/ and swap the image; ports stay the same |
| Version is pinned and updated | axllent/mailpit:v1.34.0 or newer, with Renovate or Dependabot opening bump PRs |
| Ports bound to localhost | 127.0.0.1:8025 and 127.0.0.1:1025 on laptops; private network only on shared hosts |
| Shared instances are protected | UI authentication (MP_UI_AUTH or an auth file), --allowed-hosts set, never on a public IP |
| Relay cannot email customers | allowed-recipients limited to your own domain (renamed from recipient-allowlist in 1.34.0) |
| Tests are isolated | Unique recipient per test (plus-addressing) or DELETE /api/v1/messages before each suite |
| Templates are checked | html-check and link-check run in CI for every transactional template |
| Agents get read access only | MCP server limited to reading and checks; delete and release tools disabled or not approved |
Frequently asked questions
Is MailHog still maintained?
No. MailHog has had no release for about five years, and the Mailpit README describes it as no longer maintained without security updates. In January 2026 a stored cross-site scripting vulnerability in MailHog 1.0.1 was published as CVE-2022-50908, and there is no patched version.
What is the best MailHog alternative?
For most teams, Mailpit. It uses the same ports as MailHog (SMTP 1025, web UI 8025), so switching is usually a one-line image change, and it adds a full REST API, search, HTML compatibility, link and spam checks, tags, webhooks and active security maintenance. smtp4dev is a strong choice for .NET teams or when you need IMAP, and hosted sandboxes such as Mailtrap fit teams that want shared inboxes.
Is Mailpit a drop-in replacement for MailHog?
For sending, yes: point your app at port 1025 and open the UI on port 8025 as before. What changes is the API. Tests that call MailHog’s /api/v2/messages or /api/v2/search need to move to Mailpit’s /api/v1/messages and /api/v1/search?query=to:address, which return a different JSON shape.
How do I test emails in CI?
Run Mailpit as a service container, point the application’s SMTP settings at it, and have the test poll the Mailpit API for a message to a unique recipient address. Then assert on the subject and body and follow the confirmation link. Clear the inbox before each suite or use plus-addressing so parallel workers do not read each other’s mail.
Can an AI coding agent read test emails?
Yes. Community MCP servers for Mailpit let agents such as Claude Code or Cursor search the test inbox, read a message and run the HTML, link and spam checks, and Mailtrap’s MCP server includes sandbox tools. Review community servers before installing them and give agents read and check tools only.
Further reading
- Testing your emails with MailHog: Docker and SMTP
- How to build a robust mail template system
- AI agent debugging in production
- MCP server for session data and AI agents
- LogNroll product overview
Tests cover your environment, users cover everything else. Try LogNroll for free and see what really happens when a user clicks the link in your email.