Build SMTP server with iRedMail on Ubuntu 20.04 in Simple Steps

smtp-server-iredmail

Building an SMTP server with iRedMail could be a little tricky for beginners. But it’s still easy compared to building SMTP with mailcow or Postal. If you are looking for the easiest way to build your own SMTP server then perhaps you should check building SMTP server with Mailinabox.

About iRedMail

iRedMail is an open-source mail server script with a very good number of developers contributing to its development on GitHub. It is free of cost but if you want an advanced admin panel to manage users then you have to pay for it, though the basic admin panel is free.

Features of iRedmail

iRedMail comes with inbuilt Webmail, Calendar, Contacts, ActiveSync, Antispam, Antivirus, greylisting, whitelisting, blacklisting, etc. It also supports MariaDB, PostgreSQL, OpenLDAP backends. This means you have complete freedom to choose the database type.

Perhaps iRedMail is the only mail server solution that can be installed on all versions of Linux. So, here also you have the flexibility to deploy iRedMail on your favorite Linux distribution.

Requirement

Like every mail server, you will need

  • a domain from Namecheap
  • A VPS or Cloud with minimum 2 GB RAM

I will be using Contabo for demonstration but you are absolutely free to make your choices. I already have demonstrated steps to get a domain name and VPS in the following video.

Updating DNS records

First thing first make changes to DNS records. Login to your domain registrar and create A record for mail.inlearn.in.

After that create or update MX record pointing to mail.inlearn.in with priority 10.

Then create TXT record for SPF entry and all following in value

v=spf1 mx ~all

Initial Setup

First of all, we need a way to connect to the server. Though it’s simple on Linux or MacOS, for Windows you will need an SSH client like putty or Bitvise. Download it and connect to your server

Switch to root user

sudo -i

Set the hostname or Fully Qualified Domain Name (FQDN) with the following command on Ubuntu

hostnamectl set-hostname mail.inguide.in

Don’t forget to replace inguide.in with your domain name.

Then open hosts with the following command

apt install vim -y
vim /etc/hosts

Now add the following lines and don’t forget to replace the domain name and IP

45.354.212.212 mail.inguide.in mail

Let’s update the OS.

apt update -y
apt upgrade -y

Next install gzip package

apt install gzip

Our initial setup is complete now.

Installing iRedMail

Here the first step would be to get the iRedMail. Go to iRedMail website and download the installer.

download-iredmail

Now connect to your server with any FTP client, let’s say WinSCP or FileZilla and upload the iRedMail installer. Or, alternatively download with following command

wget https://github.com/iredmail/iRedMail/archive/1.4.2.tar.gz

Next, extract it and begin the installation with the following command

ls
tar zxvf 1.4.2.tar.gz
ls
cd iRedMail-1.4.2
ls
bash iRedMail.sh

Answer the series of questions appearing on your screen to finalize the iRedMail installation.

Select email directory location

iredmail-select-email-directory-location

Select webserver type, if you don’t want to run any applications on this server you can skip it.

select-webserver

Select database type. If you want to run mail only server use OpenLDAP but if you are planning to host application as well then select MariaDB or PostgreSQL.

The following screen pops up only if you select OpenLDAP.

Specify LDAP suffix

Now type the MySQL administrator password

Finally, enter the domain name here

enter-the-domain-name

Now you will be asked to enter postmaster password

Here on this final screen, you have the option to install Webmail, Calendar, Address book & Activesync. Do not select SOGo unless your system has at least 8 GB of RAM. Make your selection then hit next.

Finally the summary of all your choices. If you want to make any modifications press CTRL+C to stop the installation and start once again. Otherwise, type Y and continue.

At the end of installation, you will be asked to change the SSH port (port 22) or continue

Now the installation has been finished. Reboot the system to enable all mail services.

Also, copy the different URLs generated for your application.

To open webmail go to https://mail.inlearn.in/mail

To open the admin panel go to https://mail.inlearn.in/iredadmin

Login with your username and password

Now here you can add domains, create users, etc.

Copying DKIM record to the DNS

To get the DKIM record go to the terminal and run the following command.

amavisd-new showkeys

The output would be something like this

dkim._domainkey.mydomain.com.   3600 TXT (
  "v=DKIM1; p="
  "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYArsr2BKbdhv9efugByf7LhaK"
  "txFUt0ec5+1dWmcDv0WH0qZLFK711sibNN5LutvnaiuH+w3Kr8Ylbw8gq2j0UBok"
  "FcMycUvOBd7nsYn/TUrOua3Nns+qKSJBy88IWSh2zHaGbjRYujyWSTjlPELJ0H+5"
  "EV711qseo/omquskkwIDAQAB")

Copy the output of command inside ( ) in one line and remove all quotes.

 v=DKIM1; p= MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYArsr2...................

After these steps secure your iRedMail server to deal with SSL warnings.

Conclusion

Installing iRedMail is easy and quick. It is loaded with several features and you have options to make a selection of features you like to install. It is a very robust system and it can easily handle a good amount of traffic.

6 replies
  1. sunil singh
    sunil singh says:

    Thank you for explaining each steps in so much detail

    i have been following your video for setting up smtp server from scratch on ubuntu server ,
    i followed mailcow, iredmail and postal …..all three cases i was able to install them successfully and login into their dashboard

    however the issue i am facing for all of them is not able to send email to any email IDs ….facing same issue with postal , iredmail and mailcow as well

    i using google cloud VM to setup the SMTP server

    Thank you,
    Sunil

    Reply

Trackbacks & Pingbacks

  1. […] so straightforward. Therefore, I had to write an article about it. If you have been following the installation of iRedMail, then already know I used the iRedMail installer in my tutorial on iRedMail. So the steps to […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *