Log inSign up

Run your own mail server with the iRedMail installer

Before anything else, open a support ticket and ask whether outgoing port 25 is available on your server, and plan to send through an authenticated relay on port 587 if it is not. Then set a hostname such as mail.example.net, download the current iRedMail release, run sudo bash iRedMail.sh on a fresh Ubuntu 24.04, Debian 12, Rocky 9 or Alma 9 server and reboot. You end up with Postfix, Dovecot, Roundcube, antispam filtering and the iRedAdmin panel, ready for TLS and DNS records.

Topic: Email servers · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

Ask about port 25 before you build anything

Confirm outgoing mail first, because a mail server that cannot deliver is only half a server. Many networks filter outbound TCP port 25 by default to keep spam down, and BitcoinVPS does not promise that it is open on every server. Open a ticket from the support tickets page, name your instance, and ask whether direct delivery on port 25 is possible. While you wait, you can still build the whole system: inbound mail on port 25, IMAP and submission work regardless.

If direct delivery is not available, or if you want a route that keeps working when a receiving provider is picky about new IP addresses, point Postfix at an authenticated SMTP relay on port 587. The steps are in send app mail through an SMTP relay, and they apply to iRedMail unchanged because iRedMail uses a normal Postfix. Use the same ticket to request a reverse DNS (PTR) record for your IPv4 and IPv6 addresses that points to mail.example.net; PTR is set by support, not from the console.

Which server size and image suit iRedMail?

Pick at least 4 GB of memory. iRedMail installs ClamAV, which keeps its virus signatures in RAM and alone uses over a gigabyte. With 2 GB the installer finishes, but the antivirus daemon tends to be killed under load. A small office with a few dozen mailboxes runs comfortably on A2-4; heavier traffic or many large attachments call for A4-8.

Deploy a clean image: Ubuntu 24.04, Ubuntu 22.04, Debian 12, Rocky Linux 9 or AlmaLinux 9. The installer expects a system with no existing web server, database or mail software, so do not use an app image and do not install anything else first. If you need to start over later, reinstall the image from the Settings tab.

How do I set the hostname and DNS before installing?

Give the server a fully qualified name that matches your mail DNS. iRedMail refuses to run when hostname -f does not return a name with a domain part.

sudo hostnamectl set-hostname mail.example.net
echo "198.51.100.24 mail.example.net mail" | sudo tee -a /etc/hosts
hostname -f

The last command must print mail.example.net. At your DNS provider, create these records (the DNS records tutorial shows A and AAAA in detail):

  • mail.example.net A 198.51.100.24 and AAAA 2001:db8:4f2a::24
  • example.net MX 10 mail.example.net

On Rocky and Alma, set SELinux to permissive because the iRedMail project does not ship policies for it: run sudo setenforce 0 and change SELINUX=enforcing to SELINUX=permissive in /etc/selinux/config.

Download and run the iRedMail installer

Fetch the newest stable release from the iRedMail download page; the commands below use version 1.7.4, so swap in the current number if a newer one is listed.

sudo apt update && sudo apt -y upgrade        # Ubuntu, Debian
sudo dnf -y upgrade                              # Rocky, Alma
VER=1.7.4
wget https://github.com/iredmail/iRedMail/archive/refs/tags/${VER}.tar.gz
tar xzf ${VER}.tar.gz
cd iRedMail-${VER}
sudo bash iRedMail.sh

The text dialog asks a short series of questions:

  • Mail storage path: keep /var/vmail unless you mounted a larger disk elsewhere.
  • Web server: Nginx is the supported choice.
  • Backend: MariaDB suits most people; OpenLDAP is useful when other systems will read the same accounts; PostgreSQL is also offered.
  • First mail domain: example.net, not the hostname.
  • Postmaster password: the admin account becomes postmaster@example.net.
  • Optional components: Roundcube, SOGo groupware, iRedAdmin, Fail2ban and netdata. Roundcube plus iRedAdmin plus Fail2ban is a lean, practical set.

Confirm the summary, let it configure the firewall, then reboot. The installer writes every generated password and path to iRedMail.tips in the same folder; copy that file somewhere safe and then delete it from the server.

How do I replace the self signed certificate?

Request a Let's Encrypt certificate with the webroot method and link it over the default files, so Postfix, Dovecot and Nginx all serve the trusted certificate.

sudo apt install certbot          # Ubuntu, Debian
sudo dnf install certbot          # Rocky, Alma (from EPEL, which iRedMail enables)
sudo certbot certonly --webroot -w /var/www/html -d mail.example.net

On Ubuntu and Debian the iRedMail files are /etc/ssl/certs/iRedMail.crt and /etc/ssl/private/iRedMail.key; on Rocky and Alma they are /etc/pki/tls/certs/iRedMail.crt and /etc/pki/tls/private/iRedMail.key. Move the originals aside and create links (Ubuntu paths shown):

sudo mv /etc/ssl/certs/iRedMail.crt{,.bak}
sudo mv /etc/ssl/private/iRedMail.key{,.bak}
sudo ln -s /etc/letsencrypt/live/mail.example.net/fullchain.pem /etc/ssl/certs/iRedMail.crt
sudo ln -s /etc/letsencrypt/live/mail.example.net/privkey.pem /etc/ssl/private/iRedMail.key
sudo systemctl restart postfix dovecot nginx

Certbot renews on a timer. Add a deploy hook in /etc/letsencrypt/renewal-hooks/deploy/ that runs systemctl reload postfix dovecot nginx so renewed files are picked up.

Publish DKIM, SPF and DMARC

The installer already created a DKIM key for your first domain; print the public part and paste it into DNS. On Ubuntu and Debian run sudo amavisd-new showkeys; on Rocky and Alma run sudo amavisd -c /etc/amavisd/amavisd.conf showkeys. The output shows a TXT record under dkim._domainkey.example.net; join the quoted pieces into one value. Then add an SPF record such as v=spf1 mx -all and a DMARC record at _dmarc.example.net. If you send through a relay, the SPF value must include it as well. The full reasoning, with lookups to verify each record, is in SPF, DKIM and DMARC records. Once DNS has updated, sudo amavisd-new testkeys (or the Rocky form with testkeys) should report pass.

Sign in to webmail and the admin panel

Open https://mail.example.net/mail/ for Roundcube and https://mail.example.net/iredadmin/ for the admin panel, both with postmaster@example.net. In iRedAdmin, add users, aliases, quotas and extra domains. Each extra domain needs its own MX record and its own DKIM key, which the iRedMail documentation explains for the backend you chose.

Mail clients connect with these settings: IMAP on 993 with SSL/TLS, SMTP submission on 587 with STARTTLS, and the full address as the username. Port 465 with implicit TLS also works for clients that prefer it.

How can I prove that mail flows both ways?

Check the listening ports, send a test, and read the log.

sudo ss -tlnp | grep -E ":(25|587|465|993|443) "
sudo systemctl status postfix dovecot --no-pager
sudo tail -f /var/log/mail.log         # Ubuntu, Debian
sudo tail -f /var/log/maillog          # Rocky, Alma

Send from Roundcube to an outside mailbox you own and reply to it. A line with status=sent means the message left; status=deferred with a connection timeout to a remote port 25 almost always means outbound 25 is closed, which is the moment to set up the 587 relay. Open the received message, view the headers and look for dkim=pass and spf=pass.

Keep the server healthy and updated

Install operating system updates regularly with apt or dnf; Postfix, Dovecot and ClamAV come from the distribution and update with it. iRedMail itself upgrades through documented step lists for each release, so read the upgrade notes on the project site rather than rerunning the installer. Watch disk use under /var/vmail with sudo du -sh /var/vmail, keep Fail2ban enabled, and consider the daily backups add-on or your own off server copies of /var/vmail and the database dumps iRedMail writes to /var/vmail/backup.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4enough memory for ClamAV and a small team2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
A4-8busier domains and larger mailboxes4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months

Questions about Mail server with iRedMail

Can this server send mail directly on port 25?

Ask support by ticket before you plan direct delivery. Whatever the answer, an authenticated relay on port 587 is the dependable way to send.

How do I get a reverse DNS (PTR) record?

Open a support ticket with your IPv4 and IPv6 addresses and the hostname, for example mail.example.net. PTR is not set from the console.

Can I install iRedMail on a server that already hosts websites?

It is not recommended. The installer replaces the web server and database configuration, so use a fresh server dedicated to mail.

Which backend should a small team choose?

MariaDB is the simplest to back up and manage through iRedAdmin. Pick OpenLDAP only if other services need to authenticate against the same directory.

Where are the passwords the installer created?

In iRedMail.tips inside the installer folder. Save a copy offline and remove it from the server.

Does iRedMail work on Debian 13?

Check the supported list for the release you download. This guide uses Debian 12, which the current release supports.