Complete Guide to Setting Up Mailpit (Without Docker)

Learn how to install and run Mailpit, a modern SMTP server for developers, directly on your Linux system without using Docker. This guide covers installation, configuration, and usage for local email testing.

Nakshara

Smart Systems.Stellar Results.

A collective of developers, designers, and engineers building scalable digital solutions and sharing practical insights from the field.

3 min read 536 words
Complete Guide to Setting Up Mailpit (Without Docker)

If you’re building apps that send emails (like OTPs, invoices, or notifications), testing them safely without sending real emails is crucial.

That’s where Mailpit comes in β€” a lightweight SMTP testing tool with a clean web UI.

In this guide, you’ll learn:

  • How to install Mailpit (no Docker)
  • Run it via terminal
  • Change UI & SMTP ports
  • Persist emails using a database
  • Run it as a background service (systemd)

πŸ“¦ What is Mailpit?

Mailpit is a local SMTP server designed for developers.

πŸ‘‰ Instead of sending real emails:

  1. Your app sends emails to Mailpit
  2. Mailpit captures them
  3. You view them in a web UI

Perfect for:

  • OTP testing
  • Email debugging
  • Development environments

πŸ› οΈ Install Mailpit (No Docker)

Step 1: Download binary

wget https://github.com/axllent/mailpit/releases/latest/download/mailpit-linux-amd64.tar.gz

Step 2: Extract

tar -xzf mailpit-linux-amd64.tar.gz

Step 3: Move to system path

sudo mv mailpit /usr/local/bin/

Step 4: Make executable

sudo chmod +x /usr/local/bin/mailpit

▢️ Run Mailpit (Basic)

mailpit

Default ports:

πŸ”§ Run with Custom Ports

Newer versions use:

  • --listen β†’ Web UI
  • --smtp β†’ SMTP server

Example:

mailpit --listen 0.0.0.0:8090 --smtp 127.0.0.1:2525

Result:

πŸ” Bind to Specific Interfaces

Public access:

mailpit --listen 0.0.0.0:8090

Local-only (safer):

mailpit --listen 127.0.0.1:8090

πŸ’Ύ Persist Emails (Optional Database)

By default, emails are stored in memory and lost on restart. To persist:

mailpit --database /var/lib/mailpit.db

πŸ‘‰ This creates a SQLite database file, separate from your app database.

βš™οΈ Run Mailpit in Background

nohup mailpit > mailpit.log 2>&1 &

Step 1: Create service file

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

Step 2: Add config

[Unit]
Description=Mailpit Email Testing Server
After=network.target

[Service]
ExecStart=/usr/local/bin/mailpit 
Restart=always
RestartSec=5
User=root

[Install]
WantedBy=multi-user.target

Step 3: Enable & start

sudo systemctl daemon-reload
sudo systemctl enable mailpit
sudo systemctl start mailpit

Step 4: Check status

sudo systemctl status mailpit

Now to bind the mailpit to a specific ip and port

[Unit]
Description=Mailpit Email Testing Server
After=network.target

[Service]
ExecStart=/usr/local/bin/mailpit --listen [IP_ADDRESS] --smtp [IP_ADDRESS] --database /var/lib/mailpit.db
Restart=always
RestartSec=5
User=root

[Install]
WantedBy=multi-user.target

πŸ” Debugging Issues

Check logs:

journalctl -u mailpit -f

Test manually:

mailpit --listen 0.0.0.0:8090

Check port usage:

sudo lsof -i :8090

πŸ”₯ Firewall Setup (if needed)

sudo ufw allow 8090

πŸ§ͺ Example: Using Mailpit with Node.js

{
  host: "127.0.0.1",
  port: 1025,
  secure: false
}

πŸ‘‰ Works perfectly with Nodemailer.

🧠 Key Takeaways

  • Mailpit is a fake SMTP server for development.
  • It does NOT use your app database.
  • Emails are:
    • Temporary (default)
    • Persistent (if using --database)
  • New versions use --listen instead of --ui.

πŸš€ Final Thoughts

If you’re building anything involving emails, Mailpit is a must-have tool in your dev workflow. It’s:

  • Fast ⚑
  • Lightweight πŸͺΆ
  • Super easy to set up πŸ”§

About the Author

Nakshara

Smart Systems.Stellar Results.

A collective of developers, designers, and engineers building scalable digital solutions and sharing practical insights from the field.

Related Articles

Continue exploring topics you might find interesting

dev

Why I Chose better-sqlite3 (and Why It Broke with pnpm)

A complete guide on why better-sqlite3 is an excellent choice for Node.js projects, its performance benefits, and how to fix common native binding issues when using pnpm.

Read Article
database

PostgreSQL 18 Installation & Setup Guide for Debian and Ubuntu

A production-ready, step-by-step guide to installing PostgreSQL 18 on Debian and Ubuntu using the official PostgreSQL APT repository. Covers secure installation, user and database setup, authentication configuration, and best practices for modern web applications.

Read Article
lms

Configuring Email in Koha LMS: SMTP Setup, Cron Jobs & Production-Ready Delivery

A production-focused, step-by-step guide to configuring email in Koha LMS using the built-in SMTP module and Linux terminal tools. Covers enabling email at the instance level, processing the message queue with cron jobs, and ensuring reliable delivery of patron notices, circulation alerts, and system notifications in a live Koha environment.

Read Article

Enjoyed this article?

Get notified when I publish new content. No spam, just quality articles delivered to your inbox.