# Mailpit — Email and SMTP Testing Tool for Developers > Mailpit is a lightweight, self-hosted email testing tool with a modern web UI, SMTP server, and REST API that captures all outgoing mail so developers can inspect messages without sending them to real recipients. ## Install Save as a script file and run: # Mailpit — Email and SMTP Testing Tool for Developers ## Quick Use ```bash # Docker docker run -d --name mailpit -p 8025:8025 -p 1025:1025 axllent/mailpit # Or download binary brew install mailpit && mailpit # Point your app SMTP to localhost:1025, open http://localhost:8025 ``` ## Introduction Mailpit acts as a drop-in fake SMTP server for development and CI environments. It captures every email your application sends and displays them in a clean web interface, letting you verify HTML rendering, headers, attachments, and link tracking without any messages leaving your network. It is the modern successor to MailHog, rewritten in Go for better performance and active maintenance. ## What Mailpit Does - Runs an SMTP server on a configurable port that accepts and stores all incoming messages - Provides a responsive web UI for browsing, searching, and inspecting captured emails - Offers a REST API for programmatic access to messages, useful in automated test suites - Supports HTML rendering preview, source view, header inspection, and attachment download - Includes optional POP3 server for client-based email retrieval during testing ## Architecture Overview Mailpit is a single Go binary that embeds an SMTP server, a POP3 server, a REST API, and a web UI. Incoming messages are parsed and stored in an embedded database (default: internal storage, optionally backed by a data directory). The web frontend is a Vue.js SPA served by the same binary. There are no external dependencies, making deployment trivial. ## Self-Hosting & Configuration - Download a single binary for your platform or run via Docker with two port mappings (SMTP and HTTP) - Configure your application's SMTP settings to point to Mailpit's SMTP port (default 1025) - Set MP_UI_BIND_ADDR and MP_SMTP_BIND_ADDR environment variables to customize listen addresses - Enable SMTP authentication or TLS via command-line flags if needed for testing those code paths - Use --max to limit stored messages and prevent unbounded disk growth in long-running environments ## Key Features - Zero-dependency single binary that runs on Linux, macOS, and Windows - Real-time web UI with instant message display, full-text search, and tag filtering - REST API with endpoints for listing, reading, deleting messages and downloading attachments - SMTP relay option to selectively forward specific messages to a real mail server - Built-in spam score testing via optional SpamAssassin integration ## Comparison with Similar Tools - **MailHog** — The predecessor project, no longer actively maintained; Mailpit is its spiritual successor - **Mailtrap** — SaaS email testing service with similar features, but not self-hosted - **GreenMail** — Java-based email test server, heavier runtime requirement - **Ethereal (Nodemailer)** — Free disposable email accounts for testing, cloud-hosted only ## FAQ **Q: Is Mailpit a replacement for MailHog?** A: Yes. Mailpit was created as a modern alternative to MailHog with better performance, active development, and additional features like message tagging and link checking. **Q: Can I use Mailpit in CI pipelines?** A: Yes. Start Mailpit as a service in your CI, point your app to its SMTP port, and use the REST API to assert on captured messages in your test suite. **Q: Does Mailpit support SMTP authentication?** A: Yes. You can enable SMTP AUTH with username/password via command-line flags, useful for testing application code that requires authenticated SMTP. **Q: How do I persist messages across restarts?** A: Use the --db-file flag to specify a database file path. Without it, messages are stored in memory and lost on restart. ## Sources - https://github.com/axllent/mailpit - https://mailpit.axllent.org --- Source: https://tokrepo.com/en/workflows/b131b0fc-401c-11f1-9bc6-00163e2b0d79 Author: Script Depot