Mail-in-a-Box turns a fresh Ubuntu server into a complete mail server with one setup command: SMTP and IMAP (Postfix and Dovecot), spam filtering, webmail (Roundcube), contacts and calendar (Nextcloud-based), automatic TLS certificates, and its own DNS server, which generates SPF, DKIM, DMARC, MTA-STS and DNSSEC records for you. It’s opinionated by design: you get a correct setup with very few decisions.
Comparing options? See mailcow and Postfix + Dovecot manually.
Requirements
- A fresh Ubuntu LTS server (check the project for the currently supported version). Mail-in-a-Box takes over the machine, so don’t install other software on it.
- At least 512 MB–1 GB RAM. 2 GB is more comfortable. Disk for mailboxes.
- Outbound port 25 open, and reverse DNS (PTR) set to the box’s hostname. On VPS.DO, both are available on USA VPS plans. See email VPS and PTR records.
- A domain you control at a registrar that supports glue records (custom nameservers).
1. Choose the hostname
By convention, box.example.com. Set it on the server:
sudo hostnamectl set-hostname box.example.com
See hostname.
2. Run the installer
curl -s https://mailinabox.email/setup.sh | sudo -E bash
Read the script first if you prefer. The setup asks for:
- your first email address (e.g.
[email protected]), which becomes the admin account; - the hostname (
box.example.com); - the country and time zone.
It installs and configures everything, which takes 10–20 minutes.
3. DNS: two options
Option A: Mail-in-a-Box as your nameserver (recommended by the project). At your registrar:
- create glue records
ns1.box.example.comandns2.box.example.com, both pointing to the box’s IP; - set the domain’s nameservers to those two names.
The box then serves all DNS records itself, and keeps SPF, DKIM, DMARC, MTA-STS and DNSSEC in sync automatically. See nameservers explained.
Option B: external DNS. Keep your existing DNS provider, and copy the records Mail-in-a-Box lists under System → External DNS (A, MX, TXT for SPF, DKIM, DMARC and others). Update them whenever the box’s recommendations change.
4. Check the status page
Log in at https://box.example.com/admin, and open System → Status Checks. Everything should be green: DNS, reverse DNS, TLS certificates, blocklists and open ports. Fix any red items before relying on the server. Then provision TLS certificates from the admin panel if they weren’t issued automatically.
Use it
- Mail users and aliases: Mail → Users / Aliases. Add more domains simply by creating addresses on them, and point their DNS at the box too.
- Webmail:
https://box.example.com/mail(Roundcube). See Roundcube. - Contacts and calendar: CalDAV and CardDAV at
https://box.example.com/cloud/. - Mail clients: IMAP 993 and SMTP 465/587, with the full email address as username. See SMTP ports.
- Static website hosting for the domains (simple files in
/home/user-data/www).
Backups
Mail-in-a-Box makes nightly encrypted backups (duplicity) of /home/user-data. Configure an off-site target (S3-compatible storage, rsync to another server, or B2) under System → Backup Status. Save the backup secret key (/home/user-data/backup/secret_key.txt) somewhere safe off the server. Without it, backups can’t be restored. See backup strategy.
Updates
Re-run the setup script to upgrade to new releases:
curl -s https://mailinabox.email/setup.sh | sudo -E bash
Major Ubuntu version changes usually require a new box and restoring from backup. Follow the project’s upgrade notes.
Limitations
- One box, Ubuntu-only, no customisation: changes you make outside the admin UI may be overwritten.
- Not built for very large organisations or complex mail routing.
- Spam filtering is solid but basic compared with mailcow’s rspamd setup.
Deliverability still needs care
Even with perfect DNS, a new IP needs a good reputation. Send to engaged recipients first, keep spam complaints low, and watch the blocklist checks on the status page. See email deliverability and IP blacklists.
Quick reference
| Item | Value |
|---|---|
| Install / upgrade | curl -s https://mailinabox.email/setup.sh | sudo -E bash |
| Admin | https://box.example.com/admin |
| Webmail | /mail |
| Contacts and calendar | /cloud/ |
| User data | /home/user-data |
| Backup key | /home/user-data/backup/secret_key.txt |
Related: SPF, DKIM and DMARC and DNSSEC.