iRedMail Installation Guide for Ubuntu 22.04
iRedMail is a free and open-source mail server solution designed to deploy a complete email system. It combines tools for mail transfer, retrieval, storage, spam and virus filtering, and secure communication. Additionally, it includes a web interface for managing email accounts, domains, and server configurations.
This guide describes how to install the iRedMail server on Ubuntu 22.04.
Prerequisites
- Ensure you have an Ubuntu 22.04 server with at least 4 GB of RAM.
- Set up at least two domain DNS records pointing to your server’s IP address, such as mail.example.com and example.com.
- Access the server via SSH as a non-root user with sudo privileges.
- Submit a support ticket to request unblocking of SMTP port 25 on your instance.
- Update the server packages before starting the installation.
Install iRedMail
Follow these steps to configure the hostname, install iRedMail, and perform the initial setup.
Set the Hostname
$ sudo hostnamectl set-hostname mail.example.com
Edit the Hosts File
$ sudo nano /etc/hosts
Modify the entries for 127.0.1.1 and 127.0.0.1 to include your mail domain for correct hostname resolution.
# Part of file: /etc/hosts
127.0.1.1 mail.example.com mail
Verify Hostname
$ hostname -f
Expected output: mail.example.com
Download and Extract iRedMail
$ wget https://github.com/iredmail/iRedMail/archive/refs/tags/1.7.3.tar.gz
The command above downloads the iRedMail version 1.7.3 release file. Visit the official download page to verify the most recent version.
$ tar -xvf 1.7.3.tar.gz
$ cd iRedMail-1.7.3
$ sudo apt update
Run Installation Script
$ sudo bash iRedMail.sh
Press Enter to begin the installation wizard, then follow the prompts:
- Use the default mail storage path: /var/vmail.
- Select Nginx as the web server.
- Choose MariaDB as the backend database.
- Press Enter to accept the default LDAP suffix.
- Set a strong password for the MySQL administrator.
- Provide your domain (e.g., example.com).
- Assign a strong password for the mail administrator account.
- Optionally, select additional components to install.
Confirm installation with Y when prompted, then choose to use iRedMail’s firewall and allow SSH on port 22. Reboot afterward:
$ sudo systemctl reboot
Post Installation Setup
To ensure full email functionality, create valid MX, SPF, DKIM, and DMARC DNS records for your domain.
DNS Records Configuration
- MX Record:
 Type: MX
 Name: @
 Priority: 10
 Value: mail.example.com
- SPF Record:
 Type: TXT
 Name: @
 Value: “v=spf1 a mx ip4:192.0.2.1 -all”
Generate DKIM Record
$ sudo amavisd-new showkeys
Use the generated DKIM key output to create a TXT record like:
Type: TXT
Name: dkim._domainkey
Value: “<iredmail-dkim-data>”
$ sudo amavisd-new testkeys
Expected output: TESTING#1 example.com: dkim._domainkey.example.com => pass
DMARC Record
Create a TXT record to send aggregate reports:
Type: TXT
Name: _dmarc
Value: “v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com; pct=100”
Configure Let’s Encrypt SSL Certificates
To secure your iRedMail server using Let’s Encrypt, install and configure SSL certificates as follows:
$ sudo snap install certbot --classic
$ sudo certbot certonly --webroot -w /opt/www/well_known -d mail.example.com -m hello@example.com --agree-tos
Edit Nginx configuration files to use the generated certificates:
$ sudo nano /etc/nginx/sites-available/00-default-ssl.conf
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 and related configuration files for Postfix and Dovecot using your Let’s Encrypt paths. Restart Nginx, Postfix, and Dovecot to apply all changes.
$ sudo systemctl restart nginx postfix dovecot
Test the Mail Server
Follow the steps below to test the iRedMail server’s functionality.
Access the Administration Console
Open your web browser, such as Chrome, and navigate to the iRedMail Administration Console (iRedAdmin):
https://mail.example.com/iredadmin
Log in using the postmaster administrator email and password that you set during installation.
Create a New User
Once logged in, click the Add drop-down menu and select User to create a new email account.
On the user addition page, fill in the required email details and click Add to finalize the user creation.
Access Webmail Interface
To access the Roundcube Webmail interface, add the /mail path to your domain in a new browser window:
Sign in using your Postmaster credentials that were created during installation.
Send a Test Email
After logging in, click Compose to create a new test email and send it to your newly created user (for example, user1@example.com).
Click Send to verify that the message is successfully delivered.
Check Mail Delivery
Log out from the Roundcube interface using the Logout button in the bottom-left corner.
Next, sign in again to Roundcube, this time using the new email account you created earlier, and confirm that the test email from the postmaster account has been received.
Verify Email Headers
Open the received email and click the header link labeled Headers. Review the message headers to confirm that your domain’s DKIM values are correctly applied to all outgoing emails.
Conclusion
In this guide, you installed and configured iRedMail on Ubuntu 22.04, securing your email environment with SPF, DKIM, and DMARC authentication. With iRedMail, you can host multiple domains and operate a secure, fully functional mail server for sending and receiving emails. For additional details and configuration options, refer to the official iRedMail documentation.


