How to Install Mail-in-a-Box on Ubuntu 16.04

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Mail-in-a-Box is an open source software that allows you to become your own mail service provider in a few easy steps. You can easily turn your fresh system into a working mail server. You don’t need to be a technology expert to set it up. Mail-in-a-Box comes with lots of security features including, Fail2ban, UFW, graylisting, SPF, DKIM, DMARC, opportunistic TLS, strong ciphers, HSTS, and DNSSEC, making it easy to host a full-stack email solution for multiple domains.

Mail-in-a-Box uses the following components:

  1. Postfix: Used as the Simple Mail Transfer Protocol.
  2. Dovecot : Used as the Internet Message Access Protocol (IMAP), allowing you to sync your mail with an IMAP client such as your phone.
  3. Roundcube webmail : Used to manage your email through the web browser.
  4. Control Panel : Used to manage your mail server, including adding or removing mailboxes, changing passwords, backing up data, and changing DNS settings.
  5. Nsd4 Domain Name System : Allow you to add DNS entries to configure Sender Policy Framework (SPF), DomainKeys Identified Mail (DKIM) and Domain-based Message Authentication.

In this tutorial, we will be installing Mail-in-a-Box on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server.

Prerequisites

  1. A fresh Alibaba Cloud Ubuntu 16.04 instance.
  2. Your domain provider needs to support setting custom nameservers and glue records so you can host your own DNS on your instance.
  3. A root password is set up to your instance.

Launch Alibaba Cloud ECS Instance

First, log in to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

Set Up Hostname

Before starting, you will need to setup hostname of the instance. You can do this with the following command:

Add the following lines:

Save and close the file. Then, you will need to modify the /etc/hosts file to associate the hostname with the server’s IP address.

Add the following lines:

Save and close the file, when you are finished.

Configure Domain Name

It is recommended to delegate DNS responsibilities to the Mail-in-a-Box server. To do so, you will need to set up glue records so you can securely and correctly set up the server for email.

First, log in to your account on your domain name registrar’s site and set up a Glue Record for your domain.

Next, open your DNS panel and add the following records

Note: Replace test.example.com with your FQDN and your-server-ip with the IP address of your new server.

Install Mail-in-a-Box

You can install Mail-in-a-Box easily using Mail-in-a-Box installation script. You can run this script with the following command:

The installation script will prepare Mail-in-a-Box installer to run. Once it completed, you should see the following thanks screen which says that the installer will ask us some answers required for the complete installation of Mail-in-a-Box.

Image for post
Image for post

Here, click on the OK button. You should see the following page:

Image for post
Image for post

Here, provide your first email address that you will use to your Mail-in-a-Box control panel and use as the default email address for your server. Then, click on the OK button, you should see the following page:

Image for post
Image for post

Now, provide hostname of your server and click on the OK button. You should see the following page:

Image for post
Image for post
Image for post
Image for post

Now, select your country and region corresponding with your timezone. Then, click on the OK button. You should see the following page:

Image for post
Image for post

Here, provide your default email address to log in to the control panel. Then, click on the OK button. Once the installation has been completed successfully. You should see the following output:

Access Mail-in-a-Box

Mail-in-a-Box is now installed and configured. It’s time to access it through the web browser.

Open your web browser and type the URL https://your-server-ip/admin. You will get a security warning in your browser window.

Image for post
Image for post

Simply ignore the error and click on the Add Exception button. You should see the following page:

Image for post
Image for post

Now, click on the Confirm Security Exception button. You will be redirected to the Mail-in-a-Box login page as shown below:

Image for post
Image for post

Now, provide your email address and password. Then, click on the Sign In button. You will be redirected to the Mail-in-a-Box default dashboard as shown below:

Image for post
Image for post

That’s it.

Congratulations! You have successfully installed and configured Mail-in-a-Box server on an Alibaba Cloud Elastic Compute Service with Ubuntu 16.04. You can now add additional email addresses to your Mail-in-a-Box server and deploy it in the production environment. You are recommended to add a CA Certificate so that you can use your Mail-in-a-Box in secure production environment.

Related Alibaba Cloud Products

Alibaba Cloud DirectMail is a simple and efficient service to send email notifications and batch email quickly and efficiently without the need to build your own email server. DirectMail is a key product for serving Alibaba’s own e-commerce platforms, which includes servicing Alibaba’s record-breaking annual sales festival.

DirectMail guarantees stable and high conversion rates across various mail channels. Emails can be sent with the product console, API interface, and SMTP interface.

Reference:https://www.alibabacloud.com/blog/how-to-install-mail-in-a-box-on-ubuntu-16-04_594474?spm=a2c41.12584004.0.0

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store