Having your own email server is very attractive for a number of reasons. To begin with, your internal mail server is pretty easy to manage in a variety of ways such as setting the storage capacity of your mails. It is also very convenient when doing backups, defining attachments requirements, managing logs and attaching as many domains as possible. However, getting your own email server working is a very complicated process that has until recently been only accessible to large organizations. The aim of this tutorial is to explore how the process can be simplified through the use of iRedMail.
Working with the iRedMail install script will enable you to set up your own mail server in about 20 minutes. We shall not be looking at how to set up a Linux server since your Alibaba Cloud ECS already comes preinstalled with an operating system.
The iRedMail includes a shell script that will get the components necessary for your email server running in your ECS instance. The process is rather simple and automatic and eliminates nearly all manual processes for setting up a mail server. It supports common operating systems such as CentOS, Ubuntu, and OpenBSD. The most notable features in the iRedMail are as follows:
The following are the major components used in iRedMail and all of them are open source:
The first consideration is the specifications for your ECS instance. You should have at least 2GB of RAM on your server as the installed components take up to a GB of your RAM. Another thing to consider is if there are other components installed: it is recommended that you have a separate VPS for your websites and blogs lest you risk breaking your installations. With that in check, let us now get to the actual process of installing iRedMail:
Step 1: Ensure your IP address is not listed in the blacklist sites by checking from mxtoolbox.com and dnsbl.info. If it is, you may have to use a different instance (but it is unlikely a fresh Alibaba Cloud ECS would be blacklisted).
Step 2: you should update your ECS instance so that all the installed software is the most recent and capable of running your mail server. SSH into your server and run the command below to update:
sudo apt update sudo apt upgrade
Great, we have successfully completed the first steps at this point.
Now, in the next steps, we shall install iRedMail, which comes with the packages that we listed above. The process will install utilities such as Apache, MySQL or PostgreSQL among others such as Postfix, Dovecot, and iptables. It is the reason why we recommended that you make the installation in a clean ECS instance. Now follow the steps below:
FQDN stands for fully qualified domain name, and this step involves the setting up of a hostname to run on our ECS instance. This step is very crucial as it will be the cornerstone of your emailing service. Run the command indicated below to see the current hostname:
You should see the hostname in the location below:
sudo nano /etc/hostname
The command below will set the fully qualified domain name (FQDN) of your server:
sudo hostnamectl set-hostname mail.example.com
To update the /etc/hosts file, navigate to the path below and list the FQDN hostname as the first item on the list:
sudo nano /etc/hosts
Your listed FQDN item listed in the location above should be as below
127.0.0.1 mail.example.com localhost
Replace the URL above with your own and ensure that you have used the address of the local host just as is seen above.
Now, you should run the command below to ascertain that the intended changes have taken effect:
Sometimes you may be forced to reboot the VPS for the changes to take effect. If even after the reboot the changes are still unavailable, repeat the process of FQDN setup illustrated above. If all looks good, let us now proceed to the next step of this process.
MX records are particularly important in email forwarding since they help resolve email hosts. For instance,
example.com's email host can be
mail.example.com. When sending an email to
example.com's server, its MX record will first be queried to figure out the emails host for that server. The A record will the be queried to resolve the target IP address so that the email can be sent .
In this step, we shall set both the MX and A records of our domain. Usually, an MX record points to the FQDN of the mail server. See details below:
Record Type Name Value MX @ mail.example.com
Next is the A record
Record Type Name Value A mail Server-IP
For IPv6 addresses, ensure that the AAAA record is also added.
Great, let us now proceed to the next step
Now, in this step, we shall disable SELinux so that iRedMail can successfully run in our VPS. It is noteworthy that the two are incompatible and our mail server will not work until the SELinux is disabled.
You will need to access the SELinux configuration in the
/etc/selinux/config file. In the file, you should set its value as 'disabled' as indicated in the below:
sudo nano /etc/selinux/config SELINUX=disabled
Great, we have successfully completed this step. Let us now proceed to the next step, which is to download iRedMail.
In this step, we shall download iRedMail to our VPS from the official download page. As a rule, always work with the most stable version rather than the most recent. Once that is done, unpack the files in a folder in readiness for the installation process:
The command below will download the iRedMail files to your server:
Once that is complete, run the extraction command below:
tar xjf iRedMail-0.9.8.tar.bz2
Remove the downloaded file like so:
sudo rm -r iRedMail-0.9.8.tar.bz2
Now, we are all set for the final installation of iRedMail after the iRedMail tarball has been extracted to your VPS.
We already have all the necessary components for the installation process. We shall not dwell so much on the questions that you shall be required to answer during this process because they are all straight-forward. Run the command below for this next step:
cd iRedMail-0.9.8 bash iRedMail.sh
Follow the prompts to start the installation process. All packages will be automatically installed and configured for your mail server. Once the run is complete, you have successfully installed iRedMail in your VPS.
After you run the commands above, you will be prompted to press Enter to accept the installation. You will also be required to set the path for mailbox storage or simply leave the default at /var/vmail.
Select your preferred web server or leave Nginx as the default.
Next, choose the database that will store email accounts from the options provided, I chose MariaDB but you can make a different choice.
Next, create a password for the database root user on localhost.
Next, create an email account and set the password or simply create a password for the default email@example.com account.
Next, choose additional plugins to add extra features as you may find useful, review your choices and press Enter to install.
Authorise iRedMail firewall rules and then restart the firewall by running the commands below:
sudo ufw enable sudo ufw reload
Finally, restart your server by running the command below:
The admin panel should now be accessible at
For more information about your server, open the tips files like so:
sudo nano /root/iRedMail-0.9.8/iRedMail.tips
Finally, note that this tutorial is for demonstration purposes and the MX and A records used are not valid. We have also used a fictional DNS name. A setup that will send emails and receive them requires the use of real configurations for use by Postfix.
If you opt to use iRedMail, you will enjoy a number of features that you will find useful. Some of the most notable of these are as discussed below:
Congratulations for making it this far, you have successfully deployed your mail server. Access the iRedAdmin via
https://example.com/iredadmin and then login using the credentials you created during the installation process If you want to test if the configurations work properly, you may want to use services such as Mail Tester. Mail Tester is used by many developers to check what aspects of their configurations need some improvements.
Alibaba Clouder - August 11, 2020
Alibaba Clouder - March 28, 2018
Alibaba Clouder - April 26, 2019
francisndungu - August 3, 2018
Alibaba Clouder - January 27, 2020
Alibaba Clouder - February 20, 2020
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
Apsara Stack Agility Elastic Compute Service (Alibaba Cloud ZStack) is a light-weight hybrid cloud solution.Learn More
Alibaba Mail is one of the only email service providers in the industry that supports public cloud services and provides fast, secure, and stable services.Learn More
Web App Service allows you to deploy, scale, adjust, and monitor applications in an easy, efficient, secure, and flexible manner.Learn More
More Posts by Alex