How to Host Your Own Mail Server on a VPS with Mail-in-a-Box
Leave a comment on How to Host Your Own Mail Server on a VPS with Mail-in-a-Box
Although managing a mail server may seem difficult, Mail-in-a-Box (MiaB) has made it easier than ever. If you’ve ever thought about managing your own email system rather than depending on outside services like Gmail or Outlook, Mail-in-a-Box can assist you in doing so.

It simplifies the process of setting up a reliable mail server on your own VPS, complete with modern features like spam filtering, DKIM/DMARC, and webmail.
What Is Mail-in-a-Box?
With little setup, the open-source Mail-in-a-Box project transforms a brand-new cloud server into a fully functional mail server.
It combines a number of components into a single, manageable system, including Postfix (SMTP), Dovecot (IMAP), SpamAssassin, Nextcloud, and Roundcube webmail.
Mail-in-a-Box provides you with a web-based admin panel to manage domains, email accounts, DNS settings, and security, eliminating the need for you to manually configure dozens of services.
Why Host Your Own Mail Server?
Here are some reasons why individuals and small businesses choose Mail-in-a-Box:
- Privacy and Control: Your emails are stored on a server you control, not scanned for advertising or analytics.
- Custom Domains: Send and receive email from addresses like [email protected].
- Cost-Effective: Instead of paying per mailbox, you only pay for the VPS and domain.
- Learning Experience: It’s a great way to understand how email systems, DNS, and security protocols work.
Requirements
Before getting started, make sure you have the following:
- A VPS with at least 1GB RAM and 20GB storage. Providers like DigitalOcean, Linode, or Vultr work well.
- A domain name to create custom email addresses.
- An Ubuntu Server. Ubuntu 22.04 is advised, as Mail-in-a-Box works best with Ubuntu LTS versions.
Step-by-Step: Install Mail-in-a-Box
Step 1: Update Your VPS
First, use SSH to access your VPS and perform a system update:
sudo apt update && sudo apt upgrade -y
Step 2: Set Hostname and DNS
Set your VPS hostname. You can use a subdomain such as box.example.com:
hostnamectl set-hostname box.example.com
Next, update the DNS records with your registrar:
- A record →
box.example.com→ your VPS IP - MX record →
example.com→box.example.com - NS records → point to your box. Mail-in-a-Box manages DNS if you choose.
Step 3: Install Mail-in-a-Box
Download and run the installation script:
curl -s https://mailinabox.email/setup.sh | bash
Follow the prompts to configure:
- Your email address (admin)
- Domain settings
- SSL/TLS setup, with Let’s Encrypt included
Step 4: Access the Admin Panel
Once installed, visit:
https://box.example.com/admin
Use the login information you created during installation to log in.
From here, you can:
- Create new mailboxes
- Configure DNS records
- Enable backups
- Check server health
Step 5: Connect Your Email Clients
Mail-in-a-Box supports IMAP/SMTP, so you can use popular email clients like:
- Thunderbird
- Apple Mail
- Outlook
- Mobile email apps
It also includes Roundcube webmail, so you can log in from any browser.
Conclusion
Mail-in-a-Box is one of the easiest ways to host your own mail server on a VPS. Incorporating all necessary services into a single automated package allows you to operate email on your own domain with privacy and autonomy.
If you’re a small business owner, tech enthusiast, or privacy advocate, hosting your own mail server with Mail-in-a-Box could be a rewarding project.
Just keep in mind that power comes with responsibility. In order to get the best results, you must maintain the security and reputation of your server.
At RackNerd, you can deploy a VPS with the resources and flexibility needed to build and manage your own server environment.