How to Setup Email Server with Mailinabox on Ubuntu 14.04

Mailinabox is a free and open source software that deploys a complete full stack email solution with a well managed server control panel in 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, webmail, and since the server itself is handling our DNS, we'll get an off-the-shelf DNS solution optimized for mail. Mailinabox has the ability to host multiple domains email and provides webmail, contacts, calendar synchronization and IMAP/SMTP server setting so that we can access our emails with mobile devices and desktop mailing clients.


Currently, mailinabox is only built for Ubuntu linux distribution so it works only on Ubuntu machines.Mailinabox currently supports only Ubuntu 14.04 LTS so, we should be running Ubuntu 14.04 LTS in order to install Mailinabox in our machine else the installer will fail to complete. We need to provision a machine with at least 768 MB of RAM whereas 1 GB memory is recommended.

Here are some steps below on how we can setup a complete email stack with Mailinabox in Ubuntu 14.04 LTS.

1. Setting up Hostname

First of all, we'll need to setup a hostname for our machine running Ubuntu 14.04 LTS. Officially, hostname of our machine should be set to so that our installation goes easy. We should setup the as a FQDN (Fully Qualified Domain Name) so that our server gets setup properly using its hostname. To do so, we'll need to edit /etc/hostname file using a text editor under sudo or root access.

# nano /etc/hostname

Then, we'll need to append the file to the following line.
Setting Hostname

Note: Please replace with your valid available FQDN.

2. Adding Hosts

Now, we'll gonna edit /etc/hosts file so that we can associate our hostname with the server's ip address where we are going to setup mailinabox. 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
Adding Hosts

Note: We'll need to replace server_ip_address with the ip address assigned to our server and with our valid domain name.

Once done, we'll gonna reboot our machine to apply the changes to the whole system.

3. Adding Glue Records

Though it is possible to have an external DNS service but it is recommended to setup a Glue Record in our DNS management panel. Using glue records makes it easier to securely and correctly set up the server for email. It is very important that all DNS responsibilities be delegated to the Mailinabox server we are going to setup, even if there's an active website using the target domain. To do so, we'll need to login to our DNS panel in the domain registrar's panel and setup a Glue Record for our domain. We can do that by simply adding ns1 and ns2 prefix to our FQDN and point it to the ip address of the server. ip-address ip-address

Then, we'll need to specify a custom DNS server for our domain to the DNS server of our box where we'll be installing Mail-in-a-Box. In this tutorial, we've the following NameServer (NS) set for our domain

Note: Here, we'll need to replace with our FQDN and ip-address with the ip address of our new server.

4. Installing MailinaBox

Now, once all the above requirements are fullfilled and successfully setup, we'll now go further towards the installation of Mail-in-a-Box. Before we go towards the installation of MailianaBox, we'll need to make sure that package named curl is installed in our machine. To install curl in Ubuntu 14.04, we'll need to execute the following apt-get package manager command.

# apt-get install curl

Once its installed, Mail-in-a-Box is pretty easy to setup in our fresh Ubuntu box by running the following curl command.

# curl -s | sudo bash
Mailinabox Installer

Running the above command will prepare mailinabox installer to run. Then, once done, we'll see the following thanks screen which says that the installer will ask us some answers required for the complete installation of Mailinabox. To continue, we'll need to select OK by hitting Enter button on the keyboard.

Setting Email Address

First question, we'll be asked to enter our first email address that we'll use to login to our Mailinabox control panel and use as the default email address for our server. And yes, we can add other email addresses later. Here, in this tutorial, we'll go with . Once its done, we'll gonna continue by selecting OK in the menu.

Configuring Hostname

Next, we'll 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'll simply leave as it is and continue further.

Selecting Country

Once its done, we'll be asked to select our country where we live. After we have selected our country, we'll 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. Then, we'll be asked to enter a password for our default email address ie which we'll use later in order to login to the control panel.

Installation Completed

After the installation process is completed, we'll be asked to open http://ip-address/admin using a web browser to browse to the Mailinabox control panel.

5. Accessing Mailinabox Panel

Now, in order to access the Mailinabox panel, we'll need to point our web browser to http://ip address/admin or domain of the serverwhere the Mailinabox is installed. To do so, here we'll point our browser to . Doing so will open an SSL warning page in our web browser. As we are using a self-signed SSL certificate in mailinabox so, we'll simply ignore the error and move ahead by confirming the certificate.

SSL Warning Mailinabox

This will open the login page of Mailinabox where we'll need to enter the default email address and password of the mail server we had set in the above step.

Login Page Mailinabox

After completing the login, we'll be welcomed to the mailinabox control panel where we'll see many menu, options to manage our email accounts, domain, DNS, SSL Certification, static website and more.

6. Accessing Webmail

Next, to access the emails, we'll need to login to the webmail client. Mailinabox has RoundCube as default web mail client. So, we'll need to point our web browser to .

Login Webmail

This will load the login page of Roundcube webmail client where we'll need to enter the email address and its password in order to login. Then, we can successfully access, send and manage our emails easily from anywhere in the internet.

Inbox Webmail Mailinabox


Finally, we have successfully installed Mailinabox Email Server Stack in our machine running Ubuntu 14.04. After installation, it is recommended to setup a CA Certificate so that we can use our mailinabox in production. We can also install Lets Encrypt CA Certificates which is available for free. It makes deployment of a secure and reliable complete stack of email server in our Ubuntu 14.04 machine. So, if you have any questions, suggestions, feedback please write them in the comment box below. Thank you ! Enjoy  :-)

3 Comments... add one

  1. Great article,

    I am novice and I've already done this, I can send/receive emails from the interface however I'd like to use this service as relay host, I want to send email from SendStudio (email marketing tool) which is hosted at another server. I've done a lot of research however couldn't find anything useful.

    Would be great if you assist in this regard.


Leave a Comment