Set up your own mailbox with Mail-in-a-Box
Mail-in-a-Box installs a complete mail server (Postfix, Dovecot, Roundcube webmail, DNS, Let's Encrypt SSL, spam filtering and an admin panel) from a single script.
WARNING
Running a mail server is ongoing work: DNS, reverse DNS (PTR), SPF/DKIM/DMARC and IP reputation all matter for deliverability. Plan for that before pointing a real domain at it.
Prerequisites
- A Gigahost VPS with Ubuntu 22.04 LTS.
- At least 1 GB RAM (2 GB recommended).
- A domain name you control.
- Reverse DNS (PTR) for the server's primary IPv4 set to your mail hostname (
mail.example.com). Set it in the Reverse DNS field on the server's Network tab. For IPv6, see Set up reverse DNS (PTR) on a routed /48 IPv6.
Step 1: point your domain at the server
In your domain registrar's DNS panel, add an A record:
| Field | Value |
|---|---|
| Host | mail |
| Type | A |
| Points to | Your server's primary public IPv4 |
Wait for DNS to propagate: a few minutes to a few hours, depending on the TTL.
TIP
Mail-in-a-Box prefers to be the authoritative DNS server for your domain, so it can manage SPF/DKIM/DMARC for you. After installation you will be told which nameservers to delegate to. If you keep DNS elsewhere, you will need to copy those records by hand.
Step 2: connect to the server
ssh root@your_server_ip
apt update && apt upgrade -yStep 3: run the installer
curl -s https://mailinabox.email/setup.sh | sudo bashIt prompts for:
- An admin email address.
- The hostname (e.g.
mail.example.com). - Confirmation of the public IP.
The whole installation takes 10-15 minutes.
Step 4: open the admin panel
When the installer finishes, browse to:
https://mail.example.com/adminLog in with the admin email + password set during install.
Step 5: create a mailbox
In the admin panel, go to Mail → Users, enter the email address (e.g. [email protected]) and a password, and click Add User.
Step 6: configure a mail client
IMAP
| Setting | Value |
|---|---|
| Server | mail.example.com |
| Port | 993 |
| Encryption | SSL/TLS |
| Username | full email address |
| Password | your mailbox password |
SMTP (submission)
| Setting | Value |
|---|---|
| Server | mail.example.com |
| Port | 587 |
| Encryption | STARTTLS |
| Auth | Required |
Step 7: verify deliverability
In the admin panel: System → Status Checks.
Make sure the report is green for:
- SPF record present and valid.
- DKIM signing key published.
- DMARC record set.
- SSL certificate valid for the mail hostname.
- PTR (rDNS) matches the server's hostname.
Mail-in-a-Box configures most of these for you, but the PTR record on your IPv4 has to be set in Flux (see Prerequisites).
Step 8: harden the host
At minimum:
- Disable root SSH login and password auth. See Secure your Linux server.
- Enable
unattended-upgradesso security patches land on their own. - Use strong passwords on every mailbox.
- Enable 2FA on the admin panel if available.
Backups
Mail-in-a-Box makes encrypted nightly backups. In the admin panel you can point them at an external destination (e.g. S3-compatible object storage) and restore from them. For mail you rely on, keep a periodic off-host copy as well.

