How To Install Mail-in-a-Box on Ubuntu 16.04 LTS

Install Mail-in-a-Box on Ubuntu 16.04 LTS

In this tutorial, we will show you how to install and configure Mail-in-a-Box on Ubuntu 16.04 LTS. For those of you who didn’t know, Mailinabox is free and open-source software that deploys a complete full-stack email solution with a well-managed server control panel in a few simple minutes. Deploying our own well-managed email server is pretty easy with Mailinabox now. It is designed to handle SMTP, IMAP/POP, spam filtering, and webmail, and since the server itself is handling our DNS, we’ll get an off-the-shelf DNS solution optimized for mail. Mailbox has the ability to host multiple domains of email and provides webmail, contacts, calendar synchronization, and IMAP/SMTP server setting so that we can access our emails with mobile devices and desktop email clients.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation Mail-in-a-Box on a Ubuntu 16.04 (Xenial Xerus) server.


  • A server running one of the following operating systems: Ubuntu 16.04 (Xenial Xerus).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Mail-in-a-Box on Ubuntu 16.04 LTS

Step 1. First, make sure that all your system packages are up-to-date by running the following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git nano curl

Step 2. Setting Hostname.

First of all, we’ll need to set up a hostname for our machine running Ubuntu 16.04 LTS. Officially, the hostname of our machine should be set to so that our installation goes easy:

nano /etc/hostname

Then, we’ll need to append the file to the following line:

Step 3. Adding Hosts.

Now, we’ll edit /etc/hosts file so that we can associate our hostname with the server’s IP address where we are going to set up a mailbox. To do so, we’ll need to execute the following command:

nano /etc/hosts

Then, we’ll need to append the file with the following lines: localhost.localdomain localhost
server_ip_address box

Step 4. Installing Mail-in-a-Box.

Run the following command to install Mail-in-a-Box:

curl -s | sudo bash

The script will prompt you with the introductory message in the following image. Press the Enter button on the keyboard:

Install Mail-in-a-Box on Ubuntu 16.04 LTS

The first question, we will be asked to enter the email address that we’ll use to login to our Mail-in-a-box control panel and use it as the default email address for our server. We can add other email addresses later. Once it is done, we will continue by selecting OK on the menu.

Install Mail-in-a-Box on Ubuntu 16.04 LTS

Next, we will be asked to enter the hostname for our mail server. As we have already set in the above step, we should be prompted with as the default hostname. So, we will simply leave it as is and continue further.

Install Mail-in-a-Box on Ubuntu 16.04 LTS

Once it is done, we will be asked to select the country where we live. After we have selected our country, we will need to hit enter to proceed ahead. This will prompt another box asking us to enter the city or region corresponding with our timezone. Doing this will exit the box and continue the installation process.

Install Mail-in-a-Box on Ubuntu 16.04 LTS

At some point, you will get this prompt:

Okay. I'm about to set up for you. This account will also have access to the box's control panel.

That’s it. You are pretty much done. All that is left is to point your domains’ DNS to Mail-in-a-Box and you will have a fully functional Mail server, webmail, calendar, web server, and contacts.

Step 5. Accessing Mail-in-a-Box Panel.

Mail-in-a-Box will be available on HTTP port 80 by default. Open your favorite browser and navigate to or http://server-ip/admin. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulations! You have successfully installed Mail-in-a-Box. Thanks for using this tutorial for installing Mail-in-a-Box on Ubuntu 16.04 LTS  (Xenial Xerus) system. For additional help or useful information, we recommend you check the official Mail-in-a-Box website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!



r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button