How to Install iRedMail on Ubuntu 24.04?
iRedMail is a free, open-source, complete mail server solution. Ubuntu is a great choice for running iRedMail because it is stable and secure.
What is iRedMail exactly?
iRedMail is a software package that sets up a full mail server. It includes email services like sending and receiving emails with secure communication. Also, it supports different databases like MySQL, MariaDB, and PostgreSQL. Moreover. iRedMail brings together different tools to handle email transfer, storage, and retrieval.
Features of iRedMail
- Web-based Mail Interface – You can check and send emails using any web browser without installing additional software. Also, manage email accounts, domains, and server settings without needing complex technical knowledge.
- Security Features – It has anti-spam, virus scanning, and antivirus protection.
- Multiple Domain Support – You can host multiple email domains on one server.
- Admin Panel – It provides a web-based control panel to manage users. You can create, modify, and delete email accounts directly from it.
- Open-Source Software – It is free and uses open-source tools. You can install and customize it according to your needs without worrying about licensing costs.
Why Use iRedMail on Ubuntu?
Ubuntu is popular for servers. It has strong security and a large community. Moreover, it works well with open-source software like iRedMail.
Also, it is super-easy to install iRedMail on Ubuntu because the software package handles most configurations. Let’s get started!
Step-by-Step Guide to Set Up iRedMail on Ubuntu 24.04
Setting up iRedMail on Ubuntu 24.04 is a great choice. This guide will walk you through the step-wise, easy process. (For more advanced configurations or troubleshooting, you can always refer to the official iRedMail documentation.)
Before You Start – What You Need
Make sure you have the following before you start the installation process –
- An Ubuntu 24.04 server with at least 4GB RAM (more is better).
- Two DNS records that point to your server’s IP address. Example: mail.example.com and example.com.
- SSH access to your server (non-root user and sudo privileges).
- Make sure port 25 (SMTP) is open. Some hosting providers block it, so you may need to request unblocking.
- Run the latest updates on your server before proceeding.
Installing iRedMail – Step by Step
Step 1 – Set the Hostname
=> First, you need to set a proper hostname for your server. So, run the below command in the terminal –
sudo hostnamectl set-hostname mail.example.com
=> Now, open the hosts file to make sure your hostname is correctly set –
sudo nano /etc/hosts
=> Update the file (from 127.0.1.1 and 127.0.0.1) so it includes your mail domain.
Part of file: /etc/hosts 127.0.1.1 mail.example.com mail
=> Check if the hostname is set correctly –
hostname -f
Did it return mail.example.com? Then, you are good to go!
Step 2 – Download and Install iRedMail
=> First, get the latest version of iRedMail. The below command is for the 1.7.2 release (check out the latest version availability here).
wget https://github.com/iredmail/iRedMail/archive/1.7.2.tar.gz
=> Now, extract the downloaded file with the below command –
tar -xvf 1.7.2.tar.gz
=> Move into the extracted directory –
cd iRedMail-1.7.2
=> Next, run the installation script –
sudo bash iRedMail.sh
Step 3: Follow the Installation Wizard
The installation wizard will ask you a series of questions.
- Mail Storage Path
Prompt Reply – Enter to keep the default /var/vmail. - Web Server Choice
Prompt Reply – Select Nginx and Enter. - Database for Mail Accounts
Prompt Reply – Choose MariaDB (press Down Arrow → Space → Enter). - LDAP Suffix (optional step if LDAP is selected instead of MariaDB/MySQL)
Prompt Reply – Enter to use the default format. - MySQL Root Password
Prompt Reply – Choose a strong password for the MySQL root user. - Your Mail Domain
Prompt Reply – Enter your domain (e.g., example.com). - Mail Admin Password
Prompt Reply – Set a strong password for the postmaster account. - Optional Components
Prompt Reply – Select any extra components you want and press Enter.
=> When asked to continue, type Y and press Enter to confirm installation settings and to allow SSH connections on port 22.
< Question > Continue? [y|N]
< Question > Restart firewall now (with ssh ports: 22)? [y|N]
=> Finally, reboot your server.
sudo systemctl reboot
Post-Installation: Setting Up DNS Records
You need to configure MX, SPF, DKIM, and DMARC records in your domain’s DNS settings so that emails work properly.
Step 4 – Add an MX (Mail Exchange) Record
Type | Name | Priority | Value |
MX | @ | 10 | mail.example.com |
Step 5 – Add an SPF (Sender Policy Framework) Record
Replace 192.0.2.1 with your actual server IP.
Type | Name | Value |
TXT | @ | “v=spf1 a mx ip4:192.0.2.1 -all” |
Example: TXT @ “v=spf1 a mx ip4:192.0.2.1 -all”
If the mail server supports IPv6 –
TXT @ “v=spf1 a mx ip4:192.0.2.1 ip6:your_ipv6_address -all”
Step 6 – Configure DKIM (DomainKeys Identified Mail)
=> Run this command to get your DKIM key that the amavisd iRedMail utility has generated –
amavisd showkeys
=> Copy everything inside the () brackets from the output and create a TXT record like this:
Type | Name | Value |
TXT | dkim._domainkey | Paste the DKIM key content here |
=> Verify your DKIM setup with the below command –
amavisd testkeys
If everything is correct, you will see a “pass” message.
Step 7 – Set Up DMARC
Type | Name | Value |
TXT | _dmarc | “v=DMARC1; p=reject; rua=mailto:[email protected]; pct=100” |
Step 8 – Secure Your Mail Server with SSL (Let’s Encrypt)
By default, it is a self-signed SSL certificate, but you should replace it with a trusted Let’s Encrypt certificate.
=>Install Certbot tool using the below command –
sudo snap install certbot --classic
=> Generate an SSL certificate (replace mail.example.com and [email protected] with your details):
sudo certbot certonly --webroot -w /var/www/html -d mail.example.com -m [email protected] --agree-tos
=> Now, let’s configure Nginx to use the SSL certificate. Open the config file –
sudo nano /etc/nginx/sites-available/00-default-ssl.conf
=> Add the below lines after server_name _; –
ssl_certificate /etc/letsencrypt/live/mail.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mail.example.com/privkey.pem;
=> Next, update the SSL template file.
$ sudo nano /etc/nginx/templates/ssl.tmpl
=> Find the ssl_certificate section and replace it as below –
ssl_certificate /etc/letsencrypt/live/mail.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mail.example.com/privkey.pem;
=> Do the same for the Postfix config; open the file –
sudo nano /etc/postfix/main.cf
=> Update the below lines of the certificate paths.
smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem
=> Do the same for Dovecot; open the file –
$ sudo nano /etc/dovecot/dovecot.conf
=> Update the SSL certificate and key paths.
ssl_cert = </etc/letsencrypt/live/mail.example.com/fullchain.pem ssl_key = </etc/letsencrypt/live/mail.example.com/privkey.pem
=> Finally, restart the services.
sudo systemctl restart nginx postfix dovecot sudo systemctl restart amavis
Step 9 – Test Your Mail Server
Once the server is up and running, it is time to test everything.
=> Open your browser and go to iRedMail Administration Console –
https://mail.example.com/iredadmin
Log in with your postmaster account and password (the admin credentials you set up during the installation).
=> In the iRedMail admin dashboard, click Add and choose User to create a new email account. Fill in the details and click Add.
=> Access Webmail by inserting /mail to domain: To check if everything’s working, open Roundcube by going to –
https://mail.example.com/mail
=> Log in using the new email user (Postmaster user and password) and Compose and Send a test email to check if it works.
Once you have sent the test email, open it and click on the “Headers” link to confirm your DKIM settings are correct.
Conclusion
And there you have it! You have successfully installed and configured iRedMail on Ubuntu 24.04. Your server is now ready to send and receive emails securely using your own mail domain. Make sure to keep your DNS records, SSL certificates, and configuration files up to date.