Skip to main content

Installation of Mail-in-a-box

Email is a vital service for any professional organization.  While services like GMail, Hotmail, and Yahoo helped bring email to the masses in a time where you had to pay to have an email account, they also brought intrusiveness, privacy violations, and excessive advertising to us as well.

In today's market, the ability to tout that you use communication platforms that are private by design is increasingly important to landing, and keeping business.  Yes, many services exist that offer privacy, encryption, and a few other bells and whistles, but each little add-on just costs you a little bit more.

Why use one of those services, that is again obfuscating what is done with your data, and where it's going, when instead you can quickly and easily setup your own domain name, and your own email server.  Mail-in-a-box makes a task that used to be so complicated and painful, you'll still find posts on the self-hosted sub-reddit warning you away from hosting your own email.  I disagree with them today, because of offerings as awesome as Mail-in-a-box.

Installing Mail-in-a-Box

What You'll Need
  • A Ubuntu 18.04 server with a Static, Public IP ( I highly recommend a VPS for this).  I used Vultr in order to get an IP that wasn't on the blacklists.
  • A domain name that you own, and can setup Glue Records for, and change the DNS Servers for.  (I use hover in the video, but feel free to use any registrar you prefer). 
  • About 30 minutes of your time.
Domain and Server IP Information

First, you need to get the Public IP of your server (a static IP - I cannot stress this enough! ).  Next, you'll want to setup two glue records for the sub-domain you'll want to use for your mail server.  The nice thing about Mail-in-a-box, is it sets up your mail server as a DNS server for your domain.  This means you can then use the Web Admin interface in Mail-in-a-box to set your other DNS A, CNAME, AAAA, and other records to point to other sub-domains you need / want.

Mail-in-a-box suggests you use the sub-domain of "box".  I find this to be just fine, so I did, but you can use any sub-domain you want...just remember what you use, and replace it accordingly throughout these intructions.

Glue Records

So, let's setup our first glue record, and call  it:

ns1.box.<your-domain.org>

Replace <your-domain.org> with your actual sub-domain name. Now enter the public IP address of your server, and save.

Next, we need to create a second glue record for our sub-domain, this one will be:

ns2.box.<your-domain.org>

Name Server Changes

Now, let's use these two Glue records, as our new DNS Servers for our domain.  Again, every domain registrar has different ways to navigate, but find where your registrar allows you to change your name servers, and let's edit the name servers they have setup for your site.  We'll want to enter the glue records we created as name server 1 and name server 2.

Now, your domain's name servers should be ns1.box.<your-domain.org> and ns2.box.<your-domain.org>.

Get Ready to Install

Now, let's do a bit of updating and upgrading, and install a couple of packages that will likely help our Mail-in-a-Box install go more smoothly.

First, let's update and upgrade our Ubuntu server.

sudo apt update && sudo apt upgrade -y

When that completes, reboot the server.  You may have gotten an new kernel installed, and you need to reboot in order for the new kernel modules to kick in.

Once rebooted, we'll install a few packages, or make sure they are already installed:

sudo apt install git wget curl -y

NOTE! Before you install Mail-in-a-box, you should not be doing so as root.  Please create a new user, and add that user to the "sudo" group, then use that user to intall Mail-in-a-box.

You can add a new user in Ubuntu with the command:

adduser <username you want>

Fill out the information as requested, then answer 'Y'.

Add your new user to the "sudo" group with the command:

usermod -aG sudo <your username>

Logoutfrom root, and log back in with your new user.  Now we can run the installer for Mail-in-a-box.

curl -s https://mailinabox.email/setup.sh | sudo -E bash

As the installer runs, it will prompt you for a few bits of information.  It will ask for your subdomain / domain name for the server. If you are following along with me would be box.<your-domain.org>

It will also ask you to enter the admin email address, use whatever email you want.  I like to just use myname@mydomain.org, then enter a password for your new email. This will be the admin user for the Mail-in-a-box admin interface, as well as your email address on the system.

When the installation completes, you'll be able to reach your Admin interface at the web address:

https://box.<your-domain.org>/admin

You can login with the email and password you just created.

You can access your email at

https://box.<your-domain.org>/mail

and agein, you can log in with the email and password you just created.

You'll want to do a few clean up items in the Mail-In-A-Box admin interface., like getting proper SSL / TLS certificates setup from LetsEncrypt (it's  a single button click), and then you'll want to setup DNSSec.  So watch the video and make sure you do those items as well.

You now have a functioning Email Server, DNS Server, and Cloud install for Contacts and Calendars.   Well done!