Tutorials  /  Ubuntu

Install iRedMail on Ubuntu 22.04 – Secure Mail Server Setup

Ccentron Redaktion · October 2025 ·6 min read ·Ubuntu, Tutorial

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.
VM

Matching infrastructure at centron

Ubuntu servers without your own hardware: ccloud³ VMs with full root access from €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Install iRedMail

Follow these steps to configure the hostname, install iRedMail, and perform the initial setup.

Set the Hostname

Console
$ sudo hostnamectl set-hostname mail.example.com

Edit the Hosts File

Console
$ 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.

Console
# Part of file: /etc/hosts
127.0.1.1 mail.example.com mail

Verify Hostname

Console
$ hostname -f

Expected output: mail.example.com

Download and Extract iRedMail

Console
$ 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.

Console
$ tar -xvf 1.7.3.tar.gz
Console
$ cd iRedMail-1.7.3
Console
$ sudo apt update

Run Installation Script

Console
$ 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:

Console
$ 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

Console
$ 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>"

Console
$ 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:

Console
$ sudo snap install certbot --classic
Console
$ 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:

Console
$ sudo nano /etc/nginx/sites-available/00-default-ssl.conf
Code
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.

Console
$ 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:

https://mail.example.com/mail

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.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Ubuntu
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren