April 5, 2025

Mailpit: Email Testing Tool for Developers

April 5, 2025

Mailpit: Email Testing Tool for Developers

Mailpit is a modern, lightweight email testing tool designed for developers. It replaces MailHog with a better UI, full-text search, API support, and authentication. In this post, we cover its features, installation on Linux, how to use it, and how it compares to MailHog.

✨ Introduction

Hi Folks!

As developers, testing emails in a safe, isolated environment is critical during development. Tools like Mailpit help us catch mistakes, debug HTML/CSS issues in email templates, and avoid accidentally sending emails to real users in staging or dev environments.

In this post, we’ll explore Mailpit—a modern alternative to MailHog—and understand its features, installation steps, usage, and how it compares to MailHog.

🛠️ Features of Mailpit

Mailpit comes with a rich feature set tailored for modern development needs:

Modern UI: Sleek, responsive interface with search and filtering.
SMTP Server: Capture and view all outgoing emails sent by your app.
Web Interface: Web-based inbox to inspect emails.
Search Support: Powerful full-text search on emails.
Inbuilt API: RESTful endpoints to integrate or automate tasks.
Docker Support: Lightweight and easily deployable via Docker.
Authentication: UI/API login support to secure access.
Lightweight: Single binary Go-based tool with minimal dependencies.

🐧 How to Install & Configure Mailpit on Linux

1. Download Mailpit binary

Linux & Mac users can install it directly to /usr/local/bin/mailpit  with:
sudo bash < <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)
Check mailpit version: mailpit version

2. PHP Configuration

Open the php.ini  files
  1. CLI : /etc/php/8.1/cli/php.ini
  2. Apache config : /etc/php/8.1/apache2/php.ini
  3. Set value : sendmail_path = /usr/local/bin/mailpit sendmail

Note: I am using php8.1, you can use it in php7.4 or other version.

3. Restart Apache2

sudo systemctl restart apache2

Create Mailpit Service

1. Create a file mailpit.service file

sudo nano /etc/systemd/system/mailpit.service

2. To check current user:

whoami

3. To check current user's primary group

id -gn

4. Create a directory to save emails

You can use your own path to save emails locally

mkdir -p /home/logicrays/mailpit_data

5. Add the below content and Save it

Please Change your User and Group in to below conten.

Need to set your path in –db-file

[Unit]
Description=Mailpit email testing service
After=network.target

[Service]
#ExecStart=/usr/local/bin/mailpit
ExecStart=/usr/local/bin/mailpit --db-file=/home/logicrays/mailpit_data/mailpit.db
#Restart=on-failure
Restart=always
RestartSec=5

User=logicrays
Group=logicrays

[Install]
WantedBy=multi-user.target

Mailpit commands

# Reload system
sudo systemctl daemon-reload

# Enable Mailpit
sudo systemctl enable mailpit

# Start Mailpit
sudo systemctl start mailpit

# Stop Mailpit
sudo systemctl stop mailpit

# Restart Mailpit
sudo systemctl restart mailpit

# Check status Mailpit
sudo systemctl status mailpit

# Verify Auto-Start Configuration
systemctl is-enabled mailpit

How to use

mailpit

✅ Conclusion

If you’re still using MailHog for email testing, it’s time to try Mailpit—a more modern, actively maintained, and feature-rich tool. 

Whether you’re working locally or inside Docker, Mailpit fits right into your workflow and keeps your email testing secure, fast, and efficient.

📦 Give it a try and upgrade your dev environment today!

Thank you for reading this article.

Share on:
Share on:
LinkedIn
Email
Facebook
Reddit
Twitter
WhatsApp
Skype
Print

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

Recent posts

LogicRays Blogs

Read other latest blogs on technology, trending, Web & Mobile App, E-Commerce related etc.
We recommend
Featured posts

Table of Contents