How to Install Mailpit on Ubuntu 24.04
Mailpit is a lightweight and fast email testing tool that provides an SMTP server for catching emails and a simple web interface for viewing them. The following steps describe how to install and configure Mailpit on Ubuntu 24.04.
Step 1 – Update the System
Update the package index to ensure the system is up to date:
sudo apt update
Step 2 – Install Required Packages
Install the necessary dependencies used to fetch and run the Mailpit installer:
sudo apt install -y curl bash
These packages provide the utilities required to download and execute the official Mailpit installation script.
Step 3 – Create a Dedicated Mailpit User
Create a system user to run Mailpit securely:
sudo useradd -r -s /usr/sbin/nologin -M mailpit
Running Mailpit under a non-root account enhances overall system security.
Step 4 – Download and Install Mailpit
Download and install the Mailpit binary using the official installation script:
sudo bash -c 'INSTALL_PATH=/usr/local/bin bash -c "$(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)"'
This command retrieves the latest Mailpit release from GitHub and installs it in /usr/local/bin
.
Step 5 – Set Permissions
Ensure that the Mailpit binary has correct ownership and permissions:
sudo chown root:root /usr/local/bin/mailpit
sudo chmod 755 /usr/local/bin/mailpit
Proper permissions ensure that the service runs securely and is accessible system-wide.
Step 6 – Create a Systemd Service
Create a systemd unit file to manage the Mailpit service. Save the following configuration to /etc/systemd/system/mailpit.service
:
[Unit]
Description=Mailpit Service
After=network.target
[Service]
Type=simple
User=mailpit
ExecStart=/usr/local/bin/mailpit --smtp 0.0.0.0:1025 --listen 0.0.0.0:8025
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Step 7 – Enable and Start the Service
Reload systemd and start the Mailpit service:
sudo systemctl daemon-reload
sudo systemctl enable --now mailpit
Verify that the service is running correctly:
sudo systemctl status mailpit
A status of active (running) indicates successful installation.
Step 8 – Access the Mailpit Interface
Once active, Mailpit provides both SMTP and web interfaces:
-
Web UI:
http://<server_ip>:8025
-
SMTP Port:
1025
When running locally, use:
http://localhost:8025