This step-by-step guide will show you how to install and run Mail-in-a-Box on Ubuntu VPS. Mail-in-a-Box is an easy-to-deploy mail server solution that automatically configures all necessary services to provide a complete mail system, including DNS, spam filtering, webmail, and more.
Table of Contents
Toggle
* 📬 What is Mail-in-a-Box?
* ⚙️ System Requirements
* ✅ Pre-Installation Checklist
* Set Hostname
* 📨 How to Install and Run Mail-in-a-Box on Ubuntu VPS
* * Update System
* Install Git & Clone Installer
* Run the Installer
* Follow the Prompts
* 🌐 DNS Setup
* 🔐 Enabling HTTPS with Let’s Encrypt
* 📥 Accessing Mail-in-a-Box Admin Panel
* 🛡️ Security Tips
* 🧰 Troubleshooting & Maintenance
* ✅ Conclusion
### 📬 What is Mail-in-a-Box?
**Mail-in-a-Box** is an open-source project that turns a fresh Ubuntu VPS into a full-featured email server for your domain. It handles:
* SMTP (Postfix)
* IMAP/POP3 (Dovecot)
* Webmail (Roundcube)
* DNS (nsd)
* Spam protection (SpamAssassin, Postgrey)
* Encryption (Let’s Encrypt, DANE, DKIM, SPF)
See also Pros and Cons of Serverless App Hosting vs VPS Hosting
### ⚙️ System Requirements
* A fresh **Ubuntu 22.04 LTS** server (the only supported OS as of latest version)
* At least **1 GB RAM** (2 GB+ recommended)
* A **public static IPv4 address**
* A domain name pointing to the server
* Root or sudo user access
### ✅ Pre-Installation Checklist
1. **Point your domain’s A record** to your VPS IP.
2. Set **hostname** to a subdomain (e.g., `box.example.com`).
3. Ensure no mail or DNS software is already installed.
4. Allow necessary ports:
* 25 (SMTP), 587 (submission), 993 (IMAPS), 443 (HTTPS), 53 (DNS), 22 (SSH)
#### Set Hostname
sudo hostnamectl set-hostname box.example.com
Also update `/etc/hosts`:
sudo nano /etc/hosts
Add:
123.123.123.123 box.example.com box
Replace with your actual VPS IP.
## 📨 How to Install and Run Mail-in-a-Box on Ubuntu VPS
To install and run Mail-in-a-Box on Ubuntu VPS, follow the steps outlined below:
1. #### Update System
sudo apt update && sudo apt upgrade -y
2. #### Install Git & Clone Installer
sudo apt install curl git -y
git clone https://github.com/mail-in-a-box/mailinabox
cd mailinabox
3. #### Run the Installer
sudo setup/start.sh
4. #### Follow the Prompts
The script will ask:
* Admin email address
* Mail hostname (use same as your box, e.g., box.example.com)
* Timezone
* Create a password for the admin user
The installer will configure:
* DNS Server
* Postfix (SMTP)
* Dovecot (IMAP)
* Spam filtering
* HTTPS with Let’s Encrypt
See also 🚀 Deploy Nagios on Ubuntu VPS
### 🌐 DNS Setup
After install, go to:
https://box.example.com/admin
Login with the email/password you set.
Navigate to **System → External DNS** for DNS records.
Update your DNS registrar or provider (like Cloudflare, Namecheap, etc.) to match the required records:
* A records
* MX record (pointing to box.example.com)
* TXT records (SPF, DKIM, DMARC)
* NS records (if using Mail-in-a-Box as authoritative DNS)
### 🔐 Enabling HTTPS with Let’s Encrypt
Mail-in-a-Box configures Let’s Encrypt automatically. The certificates are renewed automatically via cron job.
You can verify or force renew:
sudo mailinabox
# Select "Re-run Setup"
Or manually renew:
sudo certbot renew
### 📥 Accessing Mail-in-a-Box Admin Panel
Open a browser and go to:
https://box.example.com/admin
Services provided:
* **Admin Panel:** `/admin`
* **Webmail:** `/mail` (Roundcube)
* **CardDAV/CalDAV:** `/cloud` (Nextcloud Lite)
You can also configure desktop or mobile mail clients using:
* **IMAP:** box.example.com, port 993 (SSL)
* **SMTP:** box.example.com, port 587 (STARTTLS)
See also How to Install GoToSocial on Rocky Linux VPS (10 Minute Launch Guide 🚀)
### 🛡️ Security Tips
* Use **fail2ban** (installed by default).
* Set up a firewall (UFW or iptables):
sudo ufw allow OpenSSH
sudo ufw allow 25,53,80,443,587,993/tcp
sudo ufw enable
* Regularly update:
sudo mailinabox
# Choose "Check for System Updates"
* Use strong passwords for email users.
* Configure backups under **System → Backup Status** in admin panel.
### 🧰 Troubleshooting & Maintenance
* **Re-run installer for upgrades:**
cd mailinabox
sudo setup/start.sh
* **Mail logs:**
sudo tail -f /var/log/mail.log
* **Check service status:**
sudo mailinabox
# Choose "System Status Checks"
* **Reboot services manually:**
sudo systemctl restart postfix dovecot
### ✅ Conclusion
You now know how to install and run Mail-in-a-Box on Ubuntu VPS. By following this guide, you’ll have a fully functional, self-hosted email server using Mail-in-a-Box. It’s a powerful yet beginner-friendly solution for personal or small business email hosting. Be sure to keep your server updated and your DNS records accurate to maintain reliable mail delivery.
__________________
Add as Preferred Source on Google
How to Install and Run Mail-in-a-Box on Ubuntu VPS This step-by-step guide will show you how to install and run Mail-in-a-Box on Ubuntu VPS. Mail-in-a-Box is an easy-to-deploy mail server solution ...
#Guides #Cloud #VPS #certbot #lets #encrypt #mail #in #a #box #open
Origin | Interest | Match