π Mailpit Installer
A simple shell script to install and manage Mailpit β a lightweight email testing tool β on Linux or macOS. π¨
β Maintained by Asif Ahmad Khan β mailpit-setup
This script:
- ποΈ Downloads the latest Mailpit release
- π Installs the binary to
/usr/local/bin
(or custom path) - π§ Creates a systemd service for auto-start
- π€ Adds a system user
mailpit
- π οΈ Supports uninstall
- π Enables and starts Mailpit on boot
π§ Requirementsβ
- π§ Linux (x86_64 / arm64 / 386) or π macOS
curl
,tar
jq
,awk
, orsed
(for parsing GitHub API)systemd
(for service support)
βοΈ Installation Optionsβ
πΎοΈ OPTION 1: Default (Quick Install)β
Installs Mailpit with default ports and binary path.
curl -sSL https://raw.githubusercontent.com/asifkhan03/mailpit-setup/main/mailpit-install.sh | sudo bash
- π§ Installs to:
/usr/local/bin
- π Web UI:
http://localhost:8025
- π¬ SMTP:
localhost:1025
πΎοΈ OPTION 2: Custom Install (Download & Run Manually)β
Step 1: Download the script
curl -O https://raw.githubusercontent.com/asifkhan03/mailpit-setup/main/mailpit-install.sh
chmod +x mailpit-install.sh
Step 2: Run with custom values
β Custom portsβ
MAILPIT_UI_PORT=8080 MAILPIT_SMTP_PORT=2525 sudo ./mailpit-install.sh
β Custom install pathβ
sudo ./mailpit-install.sh --install-path /opt/mailpit
β Use GitHub token for higher API limitβ
GITHUB_TOKEN=ghp_your_token sudo ./mailpit-install.sh
β Uninstallβ
sudo ./mailpit-install.sh --uninstall
π οΈ Service Commandsβ
# Check status
systemctl status mailpit
# Restart Mailpit
sudo systemctl restart mailpit
# View logs
journalctl -u mailpit -f
π Environment Variablesβ
Variable | Default | Description |
---|---|---|
MAILPIT_UI_PORT | 8025 | Port for the Web UI |
MAILPIT_SMTP_PORT | 1025 | Port for the SMTP listener |
GITHUB_TOKEN | (none) | GitHub token for rate-limit bypass |
β What is Mailpit?β
Mailpit is a tool to:
- βοΈ Intercept and display SMTP messages (great for dev/staging)
- π§± Offer a simple Web UI to browse emails
- β Avoid accidentally sending real emails during development
GitHub: axllent/mailpit
π¬ Testing Mailpit with CLI and Python
Once you've installed and started Mailpit (via mailpit-setup), hereβs how you can test if it's working correctly.
Mailpit listens by default:
- Web UI: http://localhost:8025
- SMTP:
localhost:1025
β
Option 1: Test using sendemail
command-line toolβ
πΉ Step 1: Install sendemail
β
sudo apt update
sudo apt install sendemail libio-socket-ssl-perl libnet-ssleay-perl -y
πΉ Step 2: Send a test emailβ
sendemail -f [email protected] \
-t [email protected] \
-u "Mailpit Test Email" \
-m "This is a test email sent via sendemail on port 1025." \
-s localhost:1025
β Now check Mailpit UI at http://localhost:8025 β youβll see the test email there.
π Option 2: Test using a Python scriptβ
πΉ Step 1: Create a script named test_mail.py
β
# test_mail.py
import smtplib
from email.mime.text import MIMEText
msg = MIMEText("This is a test email from Python to Mailpit")
msg['Subject'] = "Python β Mailpit"
msg['From'] = "[email protected]"
msg['To'] = "[email protected]"
with smtplib.SMTP("localhost", 1025) as server:
server.send_message(msg)
print("β
Mail sent!")
πΉ Step 2: Run itβ
python3 test_mail.py
π§ Then check: http://localhost:8025
π§ͺ Pro Tip: Testing with HTML or attachmentsβ
Want to test HTML or attachments via Mailpit? Let me know and Iβll give you an example script.
π Troubleshootingβ
-
Make sure Mailpit is running:
systemctl status mailpit
-
If you're using a remote server, open ports
8025
and1025
in your firewall or security group.
Made with β€οΈ by Asif Ahmad Khan
π Licenseβ
MIT Β© Asif Ahmad Khan π¨βπ»