---
title: How to Install iRedMail on Ubuntu 24.04
url: https://docs.vultr.com/how-to-install-iredmail-on-ubuntu-24-04
description: Learn how to install iRedMail on Ubuntu 24.04 with our step-by-step guide. Set up a complete, secure email server solution quickly and efficiently.
publish_date: 2024-08-26T13:23:59.985749Z
last_updated: 2026-09-09T23:28:44.055308Z
author: Samuel Mwangi
header_image: https://docs.vultr.com/public/doc-assets/1915/2ad6ce9e-299f-41fb-aba8-4672a9831fb4.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

## Introduction

iRedMail is a free, open-source mail server solution designed to enable the deployment of a fully functional email system. It integrates multiple components for mail transfer, retrieval, storage, spam filtering, virus scanning, spam detection, and secure communication. In addition, iRedMail provides a web administration interface to manage email accounts, domains, and server settings.

This article explains how to install the iRedMail server on Ubuntu 24.04.

## Prerequisites

Before you begin:

* [Deploy an Ubuntu 24.04](https://vultr.com/servers/ubuntu) instance on Vultr with at least `4 GB` RAM.
* Set up at least `2` [domain DNS records pointing to the instance's IP address](https://docs.vultr.com/introduction-to-vultr-dns). For example, `mail.example.com` and `example.com`.
* Access the server [using SSH](https://docs.vultr.com/how-to-use-ssh-with-vultr-servers) as a non-root user with sudo privileges.
* [Open a new support ticket](https://console.vultr.com/support/create_ticket/) and request the SMTP port `25` to be unblocked on your instance.
* [Update the server](https://docs.vultr.com/how-to-update-a-vultr-cloud-server).

## Install iRedMail

Follow the steps below to configure the hostname for your server, install iRedMail, and configure it.

1. Open the terminal and run the following command to set the hostname.

    ```console
    $ sudo hostnamectl set-hostname mail.example.com
    ```

1. Open the `/etc/hosts` file.

    ```console
    $ sudo nano /etc/hosts
    ```

1. Update the `127.0.1.1` and `127.0.0.1` entries to include your mail domain to enable correct name resolution on your server.

    ```ini
    # Part of file: /etc/hosts

    127.0.1.1 mail.example.com mail
    ```

1. Verify the active server hostname.

    ```console
    $ hostname -f
    ```

    Output:

    ```
    mail.example.com
    ```

1. Download the latest iRedMail release file.

    ```console
    $ wget https://github.com/iredmail/iRedMail/archive/1.7.0.tar.gz
    ```

    The above command downloads the iRedMail version `1.7.1` release file. Visit the [official download page](https://www.iredmail.org/download.html) to verify the latest version to install on your server.

1. Extract files from the `tar` archive.

   ```console
   $ tar -xvf 1.7.0.tar.gz
   ```

1. Switch to the extracted iRedMail files directory.

   ```console
   $ cd iRedMail-1.7.0
   ```

1. Run the iRedMail installation script.

   ```console
   $ sudo bash iRedMail.sh
   ```

1. Press :key_enter: when prompted to start the installation wizard. Then, reply each of the following prompts to install iRedMail on your server.

    * **Default mail storage path**: Press :key_enter: to use the default `/var/vmail` directory.
    * **Preferred web server**: Keep `Nginx` selected and press :key_enter: to enable the web server.
    * **Choose Preferred backend uses to store mail accounts**: Press the :key_down: arrow key and press :key_space: to select MariaDB as the database backend.
    * **LDAP suffix**: Press :key_enter: to use the default domain format to create a directory tree.
    * **Password for MySQL administrator**: Enter a new strong password to assign the `root` database user account on your server.
    * **Your first domain name**: Enter your domain to use when sending and receiving emails on the server. For example, `example.com`
    * **Password for the mail domain administrator**: Enter a new strong password to assign the `postmaster` mail administrator account.
    * **Optional components**: Select optional components to install on your server and press :key_enter: to apply changes.
    * Enter :key_y: when prompted to continue and save your iRedMail installation options.
      
        ```
        < Question > Continue? [y|N]
        ```
    
    * Enter :key_y: to allow SSH connections on the default port `22` through the firewall.

        ```
        < Question > Restart firewall now (with ssh ports: 22)? [y|N]
        ```

1. Reboot the server to apply the iRedMail installation changes.

    ```console
    $ sudo systemctl reboot

## iRedMail Post Installation

iRedMail requires valid MX, SPF, DKIM and DMARC records on your mail domain to send and receive emails on your server. Log in to your domain registrar and set the following DNS records to enable iRedMail to send and deliver emails.

1. Create a new MX (Mail Exchange) record with the following details.

    * Type: `MX`
    * Name: `@`
    * Priority: `10`
    * Value: `mail.example.com`

1. Create a new SPF (Sender Policy Framework) record with the following details. Replace `192.0.2.1` with your actual server IP address.

    * Type: `TXT`
    * Name: `@`
    * Value: `"v=spf1 a mx ip4:192.0.2.1 -all"`

1. Create a new DKIM (DomainKeys Identified Mail) record:

    * Run the following command in your server's terminal to view your domain's DKIM records generated by the `amavisd` iRedMail utility.

        ```console
        $ amavisd showkeys
        ```

        Your output should be similar to the one below.

        ```
        ; key#1 2048 bits, s=dkim, d=example.com, /var/lib/dkim/example.com.pem
        dkim._domainkey.example.com. 3600 TXT (
        "v=DKIM1; p="
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1zj9jaznT73JQMGCB5ag"
        "iSjOEEYqMQqSHRAXMHUm05ZDzy5ypzLdLYech8R+T+5S7+We0tQ0tWMAj07rB4/U"
        "N6BX+J8ycp5Tcsg34lxEuYh34DENoQ8n0x4YLldrO/4+L5xk5pjJpsjiG6JigLPv"
        "VDDzQSB+PA8Sn8NNczxRVhTFZ4AQgma7p9AnraTV+d4zjD24RD2pAvHL45BjH6NS"
        "A4B3V3NfTf+OVbecI5dD29RsK8DIzhGW/XGsoo7G68fGwBpZdYkww3EhjpIojpbn"
        "uM7JeO7rIDbczehroujPCxn52c+AuUC+pnfJuBBMXoeQ0jqabsLfmll0+KPeSuFR"
        "EwIDAQAB")
        ```

        Copy all contents in bracelets `()` to use as your DKIM record's data.

    * Create a new `TXT` record using the generated DKIM information with the following details.

        * Type: `TXT`
        * Name: `dkim._domainkey`
        * Value:`"<iredmail-dkim-data>"`

   * Test your DKIM keys configuration using `amavisd` to verify the DNS record.

        ```console
        $ amavisd testkeys
        ```

        Output:

        ```
        TESTING#1 example.com: dkim._domainkey.example.com => pass
        ```

1. Create a new DMARC (Domain-based Message Authentication, Reporting, and Conformance) record with the following details to send aggregate reports to your administrative email `dmarc-reports@example.com`.

    * Type: `TXT`
    * Name: `_dmarc`
    * Value: `"v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com; pct=100"`

### Configure iRedMail to Use Trusted Let's Encrypt SSL Certificates

iRedMail uses a self-signed SSL certificate by default. Follow the steps below to configure iRedMail to use trusted Let's Encrypt SSL certificates on your server.

1. Install the Certbot Let's Encrypt client tool.

    ```console
    $ sudo snap install certbot --classic
    ```

1. Generate a new Let's Encrypt SSL certificate for your mail domain. Replace `mail.example.com` and `hello@example.com` with your actual details.

    ```console
    $ sudo certbot certonly --webroot -w /var/www/html -d mail.example.com -m hello@example.com --agree-tos
    ```

1. Open the default iRedMail virtual host configuration for Nginx.

    ```console
    $ sudo nano /etc/nginx/sites-available/00-default-ssl.conf
    ```

1. Add the following directives to the file after `server_name _;`. Replace `/etc/letsencrypt/live/mail.example.com/` with your actual Let's Encrypt directory.

    ```ini
    ssl_certificate /etc/letsencrypt/live/mail.example.com/fullchain.pem;

    ssl_certificate_key /etc/letsencrypt/live/mail.example.com/privkey.pem;
    ```

    Save and close the file.

    The above configuration directives enable Nginx to use your domain's trusted Let's Encrypt certificates to deliver requests on your server.

1. Open the `/etc/nginx/templates/ssl.tmpl` file.

    ```console
    $ sudo nano /etc/nginx/templates/ssl.tmpl
    ```

1. Find the following configuration directives.

    ```ini
    ssl_certificate /etc/ssl/certs/iRedMail.crt;
    ssl_certificate_key /etc/ssl/private/iRedMail.key;
    ```

1. Replace the SSL certificate and private key paths with your actual Let's Encrypt details.

    ```ini
    ssl_certificate /etc/letsencrypt/live/mail.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mail.example.com/privkey.pem;
    ```

    Save and close the file.

1. Open the main `Postfix` configuration file `/etc/postfix/main.cf`.

    ```console
    $ sudo nano /etc/postfix/main.cf
    ```

1. Find the following TLS settings section.
    
    ```ini
    # SSL key, certificate, CA
    #
    smtpd_tls_key_file = /etc/ssl/private/iRedMail.key
    smtpd_tls_cert_file = /etc/ssl/certs/iRedMail.crt
    smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtpd_tls_CApath = /etc/ssl/certs
    ```

1. Replace the `smtpd_tls_key_file` and `smtpd_tls_cert_file` with your actual Let's Encrypt certificate details.

    ```ini
    smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem
    smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem
    #smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    #smtpd_tls_CApath = /etc/ssl/certs
    ```

1. Open the Dovecot configuration file `/etc/dovecot/dovecot.conf`.

    ```console
    $ sudo nano /etc/dovecot/dovecot.conf
    ```

1. Find the following SSL configuration section.

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

1. Replace the `ssl_cert` and `ssl_key` values with your actual Let's Encrypt details.

    ```ini
    ssl_cert = </etc/letsencrypt/live/mail.example.com/fullchain.pem 
    ssl_key = </etc/letsencrypt/live/mail.example.com/privkey.pem
    ```

    Save and close the file.

1. Restart Nginx, Postfix and Dovecot to apply your configuration changes.

    ```console
    $ sudo systemctl restart nginx postfix dovecot
    ```

## Test the Mail Server

Follow the steps below to test the iRedMail server functionalities.

1. Access iRedMail Administration Console (iRedAdmin) using your domain in a web browser such as Chrome.

    ```
    https://mail.example.com/iredadmin
    ```

    Log in to the iRedMail web administration dashboard using the `postmaster` administrator email and password you set during the installation process.

    ![admin login](https://docs.vultr.com/public/doc-assets/1915/a0ff382d-b422-4a5c-81ab-1430b2ad9a93.png)

1. Click the **Add** drop-down and select **User** from the list to set up a new email account.

    ![Navigate to the user addition page](https://docs.vultr.com/public/doc-assets/1915/9866a91e-c541-413d-8550-c0d1b59568b9.png)

1. Enter your desired email information and click **Add** to create the new user.

    ![Add mail users](https://docs.vultr.com/public/doc-assets/1915/81d6e5d1-085f-43c6-bc77-5f0b3964207b.png)

1. Add the `/mail` path to your domain in new web browser window to access the Roundcube Webmail interface and manage your email accounts.

    ![Webmail console](https://docs.vultr.com/public/doc-assets/1915/ad4f7b05-3ca4-43e4-94e1-68e6b133e2e1.png)

    Enter your Postmaster user and password you set to log in to its web mail interface.

1. Click **Compose** to create a new test email to your new user's email. For example, `user1@example.com`.

    ![Log in](https://docs.vultr.com/public/doc-assets/1915/44d4fafa-9dcf-4e62-bf8f-3e58dd1554a9.png)

1. Click **Send** to send the test email and verify that it's successful.

    ![Send a test email](https://docs.vultr.com/public/doc-assets/1915/e3ee3945-b14c-47fc-a52f-5d1f4ac465cc.png)

1. Click **Logout** in the bottom left to exit the Roundcube Webmail interface.

    ![Log out](https://docs.vultr.com/public/doc-assets/1915/7cb302bf-b3da-48ff-a234-051853774a52.png)

1. Log in to Roundcube using the new email user you created earlier to access the email sent from the `postmaster` account.

    ![The test email](https://docs.vultr.com/public/doc-assets/1915/e22ee6c3-79f1-4ce0-af06-67f72c36540a.png)

1. Click the `header` link within **Headers**.

    ![Header link](https://docs.vultr.com/public/doc-assets/1915/2167c288-112c-44eb-af19-af7677095ea1.png)

1. Verify your domain's DKIM values sent to all mail domains.

    ![Headers output](https://docs.vultr.com/public/doc-assets/1915/975e3739-4cee-46be-89d7-624d1b43b7d5.png)

## Conclusion

You have installed iRedMail on Ubuntu 24.04 server and enabled secure access to email accounts using valid SPF, DKIM, and DMARC records. iRedMail supports multiple email domains and enables you to set up a secure mail server you can use to send and receive emails. For more information, visit the [iRedMail documentation](https://docs.iredmail.org/).
