How to Install Mailpit on Ubuntu 24.04
Mailpit is a lightweight, self-hosted SMTP testing tool that lets developers capture and inspect emails sent from applications during development. It provides a web interface to view emails, supports multiple SMTP ports, and stores messages locally for easy testing and debugging. Using Docker ensures a consistent, simple setup, while Ubuntu 24.04 LTS (Noble Numbat) provides a modern, secure, and stable platform.
Why Use Mailpit?
-
Development-Friendly – Capture emails without sending them to real users.
-
Web Interface – View emails, search, and inspect message contents.
-
Persistent Storage – Store messages in a local SQLite database for later review.
-
Customizable SMTP – Supports multiple ports and flexible authentication settings.
-
Docker-Ready – Easy deployment and updates through containerization.
Step-by-Step Installation
1. Connect to Your Server
Log in to your Ubuntu 24.04 server via SSH:
2. Update System and Install Prerequisites
Update package lists and upgrade existing packages:
Install required dependencies:
3. Install Docker
Add Docker’s GPG key and repository:
Install Docker packages:
Enable and start Docker:
Optionally, add your user to the Docker group for non-root access:
Log out and back in to apply group changes.
4. Prepare Mailpit Data Directory
Create a persistent directory for Mailpit messages and database:
5. Pull and Run the Mailpit Docker Container
Download the latest Mailpit image:
Run Mailpit:
Key parameters explained:
-
-p 8025:8025
exposes the Mailpit web interface. -
-p 1025:1025
exposes the SMTP server for applications to send test emails. -
-v /opt/mailpit/data:/data
stores all captured messages persistently. -
Environment variables configure maximum messages, database location, and SMTP authentication behavior.
-
--restart unless-stopped
ensures Mailpit restarts automatically on system reboot.
6. Access the Web Interface
Open a browser and navigate to: