20.4 C
Texas
angeloma
Senior Writer and partner

How to configure a mail server with iRedMail on Debian 10?

Hello, friends. In this post, I’ll show you how to set up a mail server using iRedMail on Debian 10.

Before we start…

With iRedMail, you can deploy an OPEN SOURCE, FULLY FLEDGED, FULL-FEATURED mail server in several minutes, for free.

This according to the project website.

When we say Fully Fledged we don’t exaggerate. iRedMail includes antivirus, protection tools, a web client, and many other things like calendar and so on that make it the best in its field.

This is why we recommend a server with 4Gb of RAM so you don’t have any problems deploying it. Also, the Debian server must be clean. This means that it should be freshly installed.

- Advertisement -

Besides this, you have to configure a DNS Mx with your hostname and domain name.

For example:

In this post, I will use the domain angtest.ga, and the hostname will be mail.angtest.ga

Properly configuring a DNS A (one to your domain and another to mail. [your-hostname] and MX is fundamental for us to be able to use it.

So, let’s get started.

Configure a mail server with iRedMail on Debian 10

1.- Set the hostname

Before we start we have to update our system. To do this, execute the following commands:

sudo apt update
sudo apt upgrade

Then, you can define your hostname for it to run:

sudo hostnamectl set-hostname

For this example:

sudo hostnamectl set-hostname mail.angtest.ga

Now edit the /etc/hosts file and add the following lines

127.0.0.1 mail.angtest.ga localhost

Remember to replace my hostname with yours. Then save the changes and close the editor.

2.- Download and run iRedMail on Debian 10

Now the next step is to download iRedMail by using the wget command.

wget https://github.com/iredmail/iRedMail/archive/1.3.2.tar.gz -O redmail.tar.gz

Then, decompress the downloaded file

tar xvf redmail.tar.gz

Then access the folder that is generated

cd iRedMail-1.3.2/

Give execution permissions to the iRedMail script

chmod +x iRedMail.sh

And execute it with the command sudo.

sudo bash iRedMail.sh

And it will start all the process of package installation and configuration.

1.- welcome screen
1.- welcome screen

In the next screen, you have to define the directory where the emails will be stored.

2.- Default mail storage path
2.- Default mail storage path

Then you can install Nginx to run the web client that incorporates iRedMail. If you don’t need one, you can choose not to install Nginx, otherwise install it. In this case, we will install it.

3.- Choosing the web server to install
3.- Choosing the web server to install

Now it’s up to you to choose which application to use the email server to store your contacts and accounts. The options are OpenLDAP, MariaDB, and PostgreSQL. We will choose MariaDB.

4.- Select MariaDB to store mail accounts
4.- Select MariaDB to store mail accounts

If you choose MariaDB, you have to define a root password.

Then, you have to indicate which is your domain.

5.- Type your domain to configure a email server
5.- Type your domain to configure a email server

In the next screen, you have to specify a password for the mail domain administrator. Remember that it has to be strong enough.

6.- Specify the password for the mail administrator
6.- Specify the password for the mail administrator

Now it’s time to choose the components to be used by iRedMail.

7.- Optional components of iRedMail
7.- Optional components of iRedMail

Then you will see an output where the options you have chosen are shown.

8.- Configure a email server with iRedMail
8.- Configure a email server with iRedMail

You will also be asked if you want to use the firewall rules that iRedMail offers.

9.- Accept the firewall rules
9.- Accept the firewall rules

In the end, if everything went well, you will see the following screen.

10.- iRedMail is installed
10.- iRedMail is installed

Now reboot the server.

When it restarts, you can go to https://mail.your-domain.com/iredadmin/ and you will see the login screen.

11.- iRedMail admin login screen
11.- iRedMail admin login screen

3.- Strongly recommended – Configuring the TLS certificate

In an email server, the main thing is security so we have to generate a TLS certificate. The best way to do this is to use Let’s encrypt

So, install the certbot package.

sudo apt install certbot

Then, execute the following command to generate the certificate

sudo certbot certonly --webroot --agree-tos --email [email protected] -d mail.your-domain.com -w /var/www/html/

Remember to replace the fields with your domain.

They must now be added to postfix and Dovecot.

To add them to Postfix, open the Postfix configuration file:

sudo nano /etc/postfix/main.cf

Find the lines:

smtpd_tls_key_file = /etc/ssl/private/iRedMail.key
smtpd_tls_cert_file = /etc/ssl/certs/iRedMail.crt
smtpd_tls_CAfile = /etc/ssl/certs/iRedMail.crt

And replace them with the following:

smtpd_tls_key_file = /etc/letsencrypt/live/mail.your-domain.com/privkey.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.your-domain.com/cert.pem
smtpd_tls_CAfile = /etc/letsencrypt/live/mail.your-domain.com/chain.pem

Replace mail.your-domain.com with the correct value in your case.

Save the changes and close the editor.

To apply the changes you have to restart the Postfix service

sudo systemctl reload postfix

Now it’s Dovecot’s turn. Open the application configuration file.

sudo nano /etc/dovecot/dovecot.conf

And find the lines:

ssl_cert = </etc/ssl/certs/iRedMail.crt
ssl_key = </etc/ssl/private/iRedMail.key

And replace them with the following:

ssl_cert = </etc/letsencrypt/live/mail.your-domain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.your-domain.com/privkey.pem

Again, replace mail.your-domain.com with the correct value in your case.

Save the changes and close the editor. To apply the changes, execute:

sudo systemctl reload dovecot

Now yes, the connections with our server are more secure.

4.- Preparing iRedMail to the first use

Now it’s time to create a new user to test the server.

Login to the admin panel.

12.- iRedMail admin panel
12.- iRedMail admin panel

Go to Add > Users and define an email address and password. You can also define a limit of use.

13.- Adding a mail user
13.- Adding a mail user

After that, you will see that the user has been created and you can expand or reduce the mailbox.

14.- User profile
14.- User profile

5.- Access to the mail server

Now if you can go to https://mail.your-domain.com/mail/ and see the web client

15.- Access to the mail account
15.- Access to the mail account

Now you can send and receive emails to your address.

16.- Mail server with iRedMail on Debian 10
16.- Mail server with iRedMail on Debian 10

Optionally, you can even use a third-party client such as Thunderbird. Look at the image and note the parameters to use.

17.- Thunderbird settings
17.- Thunderbird settings

In the end, the connection is successful and you can start using it.

18.- Mail server with iRedMail on Debian 10
18.- Mail server with iRedMail on Debian 10

So, enjoy it.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article