How to Set Up a Mail Server with iRedMail on Debian 13
Install iRedMail on a fresh Debian 13 server, then add the DNS records and a Let's Encrypt certificate that a working mail server needs.
iRedMail is an installer that turns a clean server into a complete mail system: Postfix, Dovecot, spam and virus filtering, webmail and a web admin panel, all configured to work together. This guide installs it on Debian 13 (trixie). Debian 12 is also supported by the current release and the steps are identical. Debian 7 "Wheezy", which older tutorials used, is long past end-of-life and is no longer supported by iRedMail.
At the time of writing the iRedMail download page lists version 1.8.10 and supports Debian 12 and 13, Ubuntu 22.04, 24.04 and 26.04, and the RHEL 9 and 10 family.
Requirements
- A fresh server. iRedMail installs and configures its own database, Postfix, Dovecot and Amavisd and may overwrite existing configuration. Do not run it on a machine that already hosts other services.
- Memory: the iRedMail documentation asks for at least 4 GB of RAM for a low-traffic production server with spam and virus scanning enabled.
- Free UID/GID 2000, 2001 and 2002. The installer creates system accounts with these IDs.
- Outbound port 25. Many providers block it by default. Ask your provider to open it before you start, because a mail server cannot deliver to other servers without it.
- A domain whose DNS you control. This guide uses
example.com, the host namemail.example.comand the address203.0.113.10.
The commands below are run as root. If you log in as another user, start a root shell with sudo -i first.
Set a fully qualified host name
The installer requires the server to have a fully qualified domain name (FQDN). Put the short host name in /etc/hostname:
mail
In /etc/hosts, list the FQDN first on the loopback line:
127.0.0.1 mail.example.com mail localhost localhost.localdomain
Check the result. If it does not print the FQDN, reboot and check again:
hostname -f
mail.example.com
Download and run the installer
Make sure the official Debian repositories are enabled in your APT sources, update the system and install the two packages the installer needs:
apt-get update
apt-get -y upgrade
apt-get install -y gzip dialog wget
Download the latest release listed on the iRedMail download page and extract it. Replace 1.8.10 if a newer version is available:
cd /root/
wget https://github.com/iredmail/iRedMail/archive/refs/tags/1.8.10.tar.gz
tar zxf 1.8.10.tar.gz
cd /root/iRedMail-1.8.10/
bash iRedMail.sh
Answer the installer's questions
The installer downloads what it needs and then walks you through a text-mode wizard:
- Welcome screen — confirm to continue.
- Mail storage path — where mailboxes are kept. The default is
/var/vmail/. - Backend — where mail accounts are stored: OpenLDAP, MariaDB or PostgreSQL. If you have no reason to prefer LDAP, choose the SQL database you know best. The backend cannot easily be changed later.
- LDAP suffix — asked only if you chose OpenLDAP.
- First mail domain — enter
example.com, not the host name. - Postmaster password — the password of
postmaster@example.com, which is both the admin account and a normal mailbox. - Optional components — Roundcube provides webmail and mail filters; SOGo adds calendars, contacts and ActiveSync. SOGo packages exist only for 64-bit x86 systems.
- Review — check the summary, type
yand press Enter to start the installation.
Near the end the installer asks a few yes/no questions, such as whether to apply its firewall rules. When it finishes, reboot the server so that all mail services start with the new configuration:
reboot
Read iRedMail.tips and log in
The installer writes a summary to /root/iRedMail-1.8.10/iRedMail.tips. It contains the URLs, account names, generated database passwords and the locations of configuration files. Read it, store a copy somewhere safe, and remove it from the server once you have done so, because it contains passwords in plain text.
The web interfaces are available at:
- Roundcube webmail:
https://mail.example.com/mail/ - SOGo groupware, if installed:
https://mail.example.com/SOGo - iRedAdmin panel:
https://mail.example.com/iredadmin/
Log in to iRedAdmin as postmaster@example.com to add domains and mailboxes. Until you install a trusted certificate, your browser will warn about the self-signed certificate that the installer generated.
Create the DNS records
Mail will not flow reliably until these records exist:
| Type | Name | Value |
|---|---|---|
| A | mail.example.com | 203.0.113.10 |
| MX | example.com | 10 mail.example.com. |
| TXT (SPF) | example.com | v=spf1 mx -all |
| TXT (DKIM) | dkim._domainkey.example.com | v=DKIM1; p=… (your public key) |
| TXT (DMARC) | _dmarc.example.com | v=DMARC1; p=reject; sp=none; adkim=s; aspf=s; rua=mailto:dmarc@example.com |
| PTR | 203.0.113.10 | mail.example.com |
The PTR (reverse DNS) record is set in your hosting control panel or by your provider, not in your own zone. To get the DKIM public key that the installer generated, run:
amavisd showkeys
On some releases the command is named amavisd-new instead. Copy only the text inside the parentheses into the TXT record, remove the quotation marks and line breaks, and keep the semicolon. After the record has propagated, amavisd testkeys should report pass. You may want to start DMARC with p=none and tighten it once you see that your own mail passes.
Install a Let's Encrypt certificate
Replace the self-signed certificate so that mail clients and browsers trust the server. iRedMail's Nginx configuration serves ACME challenges from /opt/www/well_known:
apt install -y certbot
certbot certonly --webroot --dry-run -w /opt/www/well_known -d mail.example.com
certbot certonly --webroot -w /opt/www/well_known -d mail.example.com
Point the file names that Postfix, Dovecot and Nginx already use at the new certificate, then restart the services:
mv /etc/ssl/certs/iRedMail.crt{,.bak}
mv /etc/ssl/private/iRedMail.key{,.bak}
ln -s /etc/letsencrypt/live/mail.example.com/fullchain.pem /etc/ssl/certs/iRedMail.crt
ln -s /etc/letsencrypt/live/mail.example.com/privkey.pem /etc/ssl/private/iRedMail.key
systemctl restart postfix dovecot nginx
The services only read the certificate when they start, so make renewals restart them. Run crontab -e as root and add:
1 3 * * * certbot renew --post-hook '/usr/bin/systemctl restart postfix dovecot nginx'
Verify mail delivery
Log in to Roundcube as postmaster@example.com, send a message to an external mailbox you own, and reply to it. If something does not arrive, the mail log shows why:
journalctl -u 'postfix*' --since "10 minutes ago"
If that prints nothing, the messages are in the mail log file whose location is listed in iRedMail.tips.
In the received message, look at the headers for spf=pass and dkim=pass. Failures there almost always point to a missing or mistyped DNS record.
Frequently asked questions
Can I install iRedMail on a server that already runs a website?
The iRedMail documentation says to use a fresh system. The installer replaces mail-related configuration and sets up its own web server, database and firewall rules, which can break whatever is already running. Use a separate server or virtual machine for mail.
Which backend should I choose?
All three store the same information. OpenLDAP is useful if other applications should authenticate against the same directory. MariaDB and PostgreSQL are simpler to inspect and back up if you already know SQL. The free iRedAdmin panel works with each of them.
Why do my messages land in spam at large providers?
Check, in this order: the PTR record matches mail.example.com, SPF and DKIM pass, a DMARC record exists, and your IP address is not on a public blocklist. A new IP address with no sending history is also treated cautiously for a while, however well it is configured.
How do I upgrade iRedMail later?
There is no upgrade command. Each release has an upgrade tutorial on the iRedMail documentation site that lists the manual changes from the previous version; apply them in order, one release at a time. Regular Debian security updates are still installed with apt as usual.