
iRedMail is a free, open-source mail server solution that enables the deployment of a fully functional email system. It integrates components for mail transfer, retrieval, storage, spam filtering, virus scanning, and secure communication, along with a web interface for managing email accounts, domains, and server settings.
This article explains how to install the iRedMail server on Ubuntu 22.04.
Before you begin:
Have an Ubuntu 22.04 server with at least 4 GB RAM.
Set up at least 2 domain DNS records pointing to the instance's IP address. For example, mail.example.com and example.com.
Access the server using SSH as a non-root user with sudo privileges.
Open a new support ticket and request the SMTP port 25 to be unblocked on your instance.
Follow the steps below to configure the hostname for your server, install iRedMail, and configure it.
Open the terminal and run the following command to set the hostname.
Open the /etc/hosts file.
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.
Verify the active server hostname.
Output:
Download the latest iRedMail release file.
The above command downloads the iRedMail version 1.7.3 release file. Visit the official download page to verify the latest version to install on your server.
Extract files from the tar archive.
Switch to the extracted iRedMail files directory.
Update the server package index before running the main script.
Run the iRedMail installation script.
Press Enter when prompted to start the installation wizard. Then, reply to each of the following prompts to install iRedMail on your server.
Default mail storage path: Press Enter to use the default /var/vmail directory.
Preferred web server: Keep Nginx selected and press Enter to enable the web server.
Choose backend for mail accounts: Press the Down arrow key and press Space to select MariaDB as the database backend.
LDAP suffix: Press Enter to use the default domain format for the directory tree.
MySQL administrator password: Enter a strong password for the root database user.
Your first domain name: Enter your domain to use for sending and receiving emails (e.g., example.com).
Mail domain administrator password: Enter a strong password for the postmaster mail administrator account.
Optional components: Select optional components to install and press Enter to apply changes.
Enter Y when prompted to continue and save your iRedMail installation options.
Enter Y to use firewall offered by iRedMail and allow SSH connections on the default port 22.
Enter Y to allow SSH connections on the default port 22 through the firewall.
Reboot the server to apply the iRedMail installation changes.
iRedMail requires valid MX, SPF, DKIM, and DMARC records for your mail domain to send and receive emails. Log in to your domain registrar and configure the following DNS records to enable email functionality on your iRedMail server.
Create a new MX (Mail Exchange) record with the following details.
MX@10mail.example.comCreate a new SPF (Sender Policy Framework) record with the following details. Replace 192.0.2.1 with your actual server IP address.
TXT@"v=spf1 a mx ip4:192.0.2.1 -all"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.
Your output should be similar to the one below.
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.
TXTdkim._domainkey"<iredmail-dkim-data>"Test your DKIM keys configuration using amavisd to verify the DNS record.
Output:
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.
TXT_dmarc"v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com; pct=100"Follow the steps below to configure iRedMail to use trusted Let's Encrypt SSL certificates on your server.
Install the Certbot Let's Encrypt client tool.
Generate a new Let's Encrypt SSL certificate for your mail domain. Replace mail.example.com and hello@example.com with your actual details.
Open the default iRedMail virtual host configuration for Nginx.
Add the following directives to the file after server_name _;. Replace /etc/letsencrypt/live/mail.example.com/ with your actual Let's Encrypt directory.
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.
Open the /etc/nginx/templates/ssl.tmpl file.
Find the following configuration directives.
Replace the SSL certificate and private key paths with your actual Let's Encrypt details.
Save and close the file.
Open the main Postfix configuration file /etc/postfix/main.cf.
Find the following TLS settings section.
Replace the smtpd_tls_key_file and smtpd_tls_cert_file with your actual Let's Encrypt certificate details.
Open the Dovecot configuration file /etc/dovecot/dovecot.conf.
Find the following SSL configuration section.
Replace the ssl_cert and ssl_key values with your actual Let's Encrypt details.
Save and close the file.
Restart Nginx, Postfix and Dovecot to apply your configuration changes.
Follow the steps below to test the iRedMail server functionalities.
Access iRedMail Administration Console (iRedAdmin) using your domain in a web browser such as Chrome.
Log in to the iRedMail web administration dashboard using the postmaster administrator email and password you set during the installation process.
Click the Add drop-down and select User from the list to set up a new email account.
Enter your desired email information and click Add to create the new user.
Add the /mail path to your domain in new web browser window to access the Roundcube Webmail interface and manage your email accounts.
Enter your Postmaster user and password you set to log in to its web mail interface.
Click Compose to create a new test email to your new user's email. For example, user1@example.com.
Click Send to send the test email and verify that it's successful.
Click Logout in the bottom left to exit the Roundcube Webmail interface.
Log in to Roundcube using the new email account you created earlier to access emails sent from the postmaster account.
Click the header link within Headers.
Verify your domain's DKIM values sent to all mail domains.
In this article, you installed iRedMail on an Ubuntu 22.04 server and secured email access using valid SPF, DKIM, and DMARC records. iRedMail supports multiple email domains, allowing you to set up a secure mail server for sending and receiving emails. For more information, visit the iRedMail documentation.
0 Comments
Be the first to comment and share your perspective with the community.