Email Testing Tools Comparison: Mailpit vs MailHog vs Mailtrap vs smtp4dev
Several tools exist for intercepting and testing emails during development. They all solve the same core problem — capturing outgoing SMTP traffic without delivering it — but differ in features, maintenance status, and hosting model.
The Candidates
| Tool | Type | Language | Last Release | License |
|---|---|---|---|---|
| Mailpit | Self-hosted | Go | Active (2024) | MIT |
| MailHog | Self-hosted | Go | 2017 (stale) | MIT |
| Mailtrap | Cloud SaaS | — | Active | Freemium |
| smtp4dev | Self-hosted | C# | Active (2024) | MIT |
| Papercut SMTP | Self-hosted | C# | Active | Apache 2 |
Mailpit
The current best choice for self-hosted email testing. Mailpit is actively maintained, has excellent Docker support, and exposes a clean REST API.
Setup:
docker run -d -p 1025:1025 -p 8025:8025 axllent/mailpitAPI quality: Excellent. HTML and Text are top-level fields — no MIME parsing required.
{
"ID": "abc123",
"From": { "Address": "from@example.com" },
"To": [{ "Address": "to@example.com" }],
"Subject": "Hello",
"HTML": "<p>Hello</p>",
"Text": "Hello"
}Key features:
- Full-text search over messages
- Message tagging
- SMTP authentication support
- Per-recipient filtering
- Prometheus metrics endpoint
- Optional persistence (SQLite)
Best for: New projects, teams that want a self-hosted solution with an active community.
MailHog
The original Go-based email testing tool. Still widely used due to years of documentation and tutorials, but has not had a release since 2017.
Setup:
docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhogAPI quality: Works but requires MIME parsing to extract HTML.
// MailHog requires navigating MIME parts
const htmlPart = message.MIME.Parts
.find(p => p.Headers['Content-Type'][0].includes('text/html'))
const html = htmlPart?.Body || ''Key features:
- Stable and battle-tested
- Huge ecosystem of examples and tutorials
- v2 API for listing messages
Best for: Existing projects already using MailHog. No reason to migrate, but use Mailpit for new projects.
Mailtrap
A cloud SaaS solution that requires no local setup. Mailtrap provides a managed SMTP sandbox plus a web UI for team collaboration.
Setup:
# .env.test — use Mailtrap's SMTP endpoint
SMTP_HOST=sandbox.smtp.mailtrap.io
SMTP_PORT=2525
SMTP_USER=your-mailtrap-user
SMTP_PASS=your-mailtrap-passAPI quality: Good REST API, requires account/inbox IDs and API token.
Key features:
- Shared team inbox — multiple devs see the same emails
- Spam score analysis
- HTML email preview across clients (paid)
- Email Analytics (paid)
- Mailtrap Email Sending (production SMTP, separate product)
Limitations:
- Requires internet access — no offline or air-gapped CI
- API requires account setup and credentials in CI secrets
- Rate limits on free tier
- Privacy consideration: emails sent to a third-party cloud
Best for: Teams that want shared visibility without local setup, or that already use Mailtrap's production sending product.
smtp4dev
A .NET-based self-hosted SMTP server with a web UI. Less common in the Node.js/Python ecosystem but popular in .NET shops.
Setup:
docker run -d -p 25:25 -p 80:80 rnwood/smtp4devAPI: REST API available at http://localhost:80/api/
Best for: .NET/ASP.NET projects where the team is already in the .NET ecosystem.
Feature Comparison
| Feature | Mailpit | MailHog | Mailtrap | smtp4dev |
|---|---|---|---|---|
| Self-hosted | ✓ | ✓ | ✗ | ✓ |
| Docker | ✓ | ✓ | N/A | ✓ |
| REST API | ✓ | ✓ | ✓ | ✓ |
| HTML/Text top-level | ✓ | ✗ | ✓ | ✓ |
| Search | ✓ | ✗ | ✓ | ✗ |
| Spam score | ✗ | ✗ | ✓ | ✗ |
| Persistence | Optional | ✗ | Cloud | Optional |
| Actively maintained | ✓ | ✗ | ✓ | ✓ |
| Free tier | ✓ | ✓ | ✓ (limited) | ✓ |
CI Integration
All self-hosted tools work as GitHub Actions services:
# Mailpit (recommended)
services:
mailpit:
image: axllent/mailpit
ports:
- 1025:1025
- 8025:8025
# MailHog (legacy projects)
services:
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025Mailtrap uses environment variables (API credentials) rather than a Docker service.
Decision Guide
New project, self-hosted preferred → Mailpit Clean API, active maintenance, easy Docker setup. No reason not to use it.
Existing project already using MailHog → Keep MailHog MailHog works fine. Migration effort not worth it unless you need search or persistence.
Team needs shared visibility without local tooling → Mailtrap The only option where multiple developers share the same email inbox without running local servers.
ASP.NET / .NET project → smtp4dev Native .NET tooling, integrates well with the Visual Studio ecosystem.
Migration from MailHog to Mailpit
The Docker image and port change is the only difference:
- image: mailhog/mailhog
+ image: axllent/mailpitThe main code change: stop parsing MIME parts. Mailpit returns HTML and Text directly at the message level.
- const html = msg.MIME.Parts.find(p => p.Headers['Content-Type'][0].includes('text/html'))?.Body
+ const html = msg.HTMLThat's it. API endpoints differ (/api/v2/messages → /api/v1/messages) but the structure is close enough that most helpers need minimal changes.