As a business entity you require email solution to communicate with customers and internally between the employees or other partners. Some people will opt for cloud email hosting solutions, while others will want to do in-house email hosting and be in control of everything. When choosing a mail server for your hosting there is the option of commercial or open source solutions. One of the powerful and reliable mail servers available is iRedMail.

iRedMail is packaged with all the features needed to start sending and receiving emails. Furthermore, the company behind the development of this solution offer professional support to back you up in case of major issues with the software. In this article we shall cover the installation and configuration of iRedMail on Rocky / AlmaLinux / CentOS 9 Linux servers. The following are requirements for this setup.

  1. A server with a public IP address (if receiving emails from the internet)
  2. A FQDN for the mail server
  3. A valid A record for the domain configured in your DNS server

Our setup is based on the following.

  • Server IP address: 95.217.21.164
  • Server Hostname: mail.techwizguru.com
  • Primary domain: techwizguru.com

Configure DNS records

Since I’m using cloudflare as my DNS provider, we added the following records.

  • A record
iredmail configure smtp 01
  • MX record
iredmail configure smtp 02

We can confirm this using dig command:

$ dig mx +short techwizguru.com
10 mail.techwizguru.com.

$ dig A +short mail.techwizguru.com
95.217.21.164

Prepare iRedMail Server

We’ll need to configure correct hostname on the server using domain name for the email.

sudo hostnamectl set-hostname mail.techwizguru.com

Also update timezone on the server to ensure correct timestamp is used in your emails.

sudo timedatectl set-timezone Africa/Nairobi

Edit /etc/hosts file and map manually in case of DNS challenges in resolving the domain name.

$ sudo vi /etc/hosts
95.217.21.164 mail.techwizguru.com

If you have hostname mapped to 127.0.0.1 please comment it.

#127.0.0.1 mail.techwizguru.com
#::1 mail.techwizguru.com

Set SELinux in permissive mode

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Enable EPEL and CRB repositories on the system.

sudo dnf install epel-release -y
sudo dnf config-manager --set-enabled crb

Update system

Before we perform the installation of iRedMail server on the system, let’s first update it.

sudo dnf -y update

Once it’s updated we can reboot the system.

sudo reboot

Download and extract iRedMail archive

iRedMail should always be installed on a FRESH server installation. The system you’re working on should not have mail related components installed, e.g. MySQL, OpenLDAP, Postfix, Dovecot, Amavisd, etc.

During installation process, iRedMail will install and configure the components automatically. If you install on system with older packages iRedMail will update existing files/configurations although it will backup files before modifying, and it may not be working as expected.

If doing the installation in a cloud server, confirm that Port 25, required by mail server is not blocked. Please note that many ISPs block port 25 by default. You can open a support ticket to request your cloud provider to open the port for you.

We need the following checked before installing iRedMail on Rocky / AlmaLinux / CentOS 9 system:

  • FRESH, working installation of Rocky / AlmaLinux / CentOS 9.
  • At least 4 GB of memory available for a production mail server with spam/virus scanning enabled.
  • Adequate storage space for mailboxes.

Visit the Downloads page and check supported releases. We are downloading the latest release at the time of updating this article.

VER=1.6.7
wget https://github.com/iredmail/iRedMail/archive/refs/tags/$VER.tar.gz

Extract the file you just downloaded

sudo yum -y install tar
tar -xvf $VER.tar.gz

Switch to created folder after extracting the file.

cd iRedMail-*/

Make the script executable.

chmod a+x iRedMail.sh

Begin installation of iRedMail Server

Next we run the script to begin installation of iRedMail on Rocky / AlmaLinux / CentOS 9.

sudo ./iRedMail.sh

In the welcome wizard hit “Yes” to begin installation process.

image 1

Specify the directory that will store user mailboxes. This can be set to directory or mount point with better free space.

image 2

Choose web server that will serve web pages for iRedMail server.

image 3

Select backend storage service for your mail accounts.

image 4

For LDAP you’ll need to provide domain suffix.

iredmail ldap suffix

iRedMail installs database server automatically. You’ll need to set the password for root user.

image 5

Provide the first domain name for which iRedMail will handle emails for.

iredmail add domain

Enable extra options during the installation.

iredmail more settings

At the final step you’re shown a summary of the configurations to be applied. Confirm and accept to proceed by pressing y.

*************************************************************************
***************************** WARNING ***********************************
*************************************************************************
*                                                                       *
* Below file contains sensitive information (username/password), please  *
* do remember to *MOVE* it to a safe place after installation.          *
*                                                                       *
*   * /root/iRedMail-1.x.y/config
*                                                                       *
*************************************************************************
********************** Review your settings *****************************
*************************************************************************

* Storage base directory:               /var/vmail
* Mailboxes:
* Daily backup of SQL/LDAP databases:
* Store mail accounts in:               OpenLDAP
* Web server:                           Nginx
* First mail domain name:               techwizguru.com
* Mail domain admin:                    [email protected]
* Additional components:                Roundcubemail netdata iRedAdmin Fail2ban

< Question > Continue? [y|N] y

Accept default options for all other prompts.

< Question > File: /etc/firewalld/zones/iredmail.xml, with SSHD ports: 22. [Y|n] y
< Question > Restart firewall now (with ssh ports: 22)? [y|N] y
< Question > File: /etc/my.cnf. [Y|n] y

At the end you get a printout of iRedMail access details and credentials.

********************************************************************
* URLs of installed web applications:
*
* - Roundcube webmail: https://mail.techwizguru.com/mail/
* - netdata (monitor): https://mail.techwizguru.com/netdata/
*
* - Web admin panel (iRedAdmin): https://mail.techwizguru.com/iredadmin/
*
* You can login to above links with below credential:
*
* - Username: [email protected]
* - Password: StrongPassw0rd
*
*
********************************************************************
* Congratulations, mail server setup completed successfully. Please
* read below file for more information:
*
*   - /root/iRedMail-1.x.y/iRedMail.tips
*
* And it's sent to your mail account [email protected].
*
********************* WARNING **************************************
*
* Please reboot your system to enable all mail services.
*
********************************************************************

Reboot iRedMail Server to start all mail services.

sudo reboot

Access iRedMail Admin Web Portal

All iRedMail access information will be stored in the file “/root/iRedMail-1.x/config” if script was run as root user or “~/iRedMail-1.x/config” if the script was executed as normal user.

My web admin panel will be available on https://mail.example.com/iredadmin/

image 6

The other URLs for web applications are:

  • Roundcube webmail: https://mail.example.com/mail/
  • Netdata (monitor): https://mail.example.com/netdata/

The next articles to read are:

Epilogue

iRedMail email server has proven to be enterprise ready. It is build from ground up to serve customers of varying email requirements. In this article we just covered the installation process. Kindly refer to the official documentation pages to learn more about available configuration options and recommended hardening tips.

LEAVE A REPLY

Please enter your comment!
Please enter your name here