How to Set Up a Mail Server with iRedMail on FreeBSD 14
Turn a fresh FreeBSD 14 server into a complete mail server with iRedMail: Postfix, Dovecot, spam and virus filtering, webmail and an admin panel, plus the DNS records it needs.
iRedMail is an open-source installer that turns a clean server into a full mail system: Postfix for SMTP, Dovecot for IMAP and POP3, Amavisd with SpamAssassin and ClamAV for filtering, Nginx with Roundcube webmail, and the iRedAdmin web panel for managing domains and mailboxes. This guide installs it on FreeBSD 14 and covers the FreeBSD-specific paths and service handling you need afterwards.
iRedMail's download page lists FreeBSD 14.x as the supported FreeBSD line. FreeBSD 10 has been end-of-life for years, and FreeBSD 15 is not on iRedMail's supported list at the time of writing, so use a supported 14.x release such as 14.5-RELEASE.
Requirements
- A fresh, minimal FreeBSD 14.x installation with no other mail, web or database software. The installer overwrites existing configuration, so never run it on a server that is already in production.
- At least 4 GB of memory for a low-traffic production server with spam and virus scanning enabled. ClamAV alone needs a large share of that.
- A fully qualified hostname such as
mx.example.comwith an A record pointing to the server, and the ability to set reverse DNS (PTR) for the IP address in your hosting control panel. - Outbound and inbound TCP port 25. Many hosting providers block it by default; ask your provider to open it before you start, because a mail server cannot work without it.
- UIDs and GIDs 2000, 2001 and 2002 must be unused. They are on a fresh system.
- Root access. All commands below are run as
root.
Step 1: Update the system and set the hostname
Apply the latest FreeBSD patches and bring the package database up to date:
freebsd-update fetch install
pkg update -f
pkg upgrade
Reboot if freebsd-update installed a new kernel.
iRedMail requires the server's hostname to be a fully qualified domain name. Check the current value:
hostname -f
Set it permanently in /etc/rc.conf:
sysrc hostname="mx.example.com"
Then edit /etc/hosts so the fully qualified name is the first name on the loopback line:
127.0.0.1 mx.example.com mx localhost localhost.localdomain
Apply the name to the running system and verify it. If the output is still the old name, reboot.
hostname mx.example.com
hostname -f
Step 2: Install the installer's prerequisites
The installer is a Bash script with a dialog-based interface. FreeBSD's default shell is not Bash, so install both tools from packages:
pkg install bash cdialog
Step 3: Download iRedMail
Look up the current stable version on the iRedMail download page; this guide uses 1.8.10. Replace the version number in the commands if a newer one has been released.
cd /root
fetch -o iRedMail-1.8.10.tar.gz https://github.com/iredmail/iRedMail/archive/refs/tags/1.8.10.tar.gz
tar zxf iRedMail-1.8.10.tar.gz
Step 4: Run the installer
Start the installer with Bash:
cd /root/iRedMail-1.8.10
bash iRedMail.sh
It asks a short series of questions:
- Mail storage path. The default is
/var/vmail. Put it on the file system with the most space, since all mailboxes live there. - Backend for mail accounts. OpenLDAP, MySQL/MariaDB or PostgreSQL. They are functionally equivalent for iRedMail, so choose the one you know how to administer. If you have no preference, the SQL backends are simpler to maintain than LDAP.
- LDAP suffix, only if you chose OpenLDAP, for example
dc=example,dc=com. - First mail domain, for example
example.com. It must not be identical to the server's hostname. - Password for the domain administrator
postmaster@example.com. This account is both the admin login for iRedAdmin and a normal mailbox. - Optional components. Roundcube is plain webmail. SOGo adds calendars, address books and ActiveSync. You can install both, but mail filter rules can then only be managed in Roundcube.
Review the summary, type y and press Enter. The installer then downloads and installs the required FreeBSD packages with pkg and configures every service. It asks one or two closing questions, such as whether to apply its firewall rules; read each prompt before answering, and make sure SSH stays reachable if you accept firewall rules on a remote server.
For the SQL backends the installer generates a strong random password for the database administrator instead of asking you for one.
When it finishes, reboot so that every service starts cleanly from /etc/rc.conf:
shutdown -r now
Step 5: Read iRedMail.tips and log in
Everything the installer generated is recorded in one file: URLs, user names, passwords and configuration file locations.
less /root/iRedMail-1.8.10/iRedMail.tips
This file contains passwords in clear text. Copy it to a safe place off the server, then delete it or at least make sure it stays readable by root only. The same directory contains a config file with the answers you gave; remove it as well once you no longer need it.
The web interfaces are available at:
- Roundcube webmail:
https://mx.example.com/mail/ - SOGo groupware, if installed:
https://mx.example.com/SOGo - iRedAdmin panel:
https://mx.example.com/iredadmin/
Log in with postmaster@example.com and the password you chose. The browser warns about the certificate because iRedMail starts with a self-signed one, stored at /etc/ssl/certs/iRedMail.crt with its key at /etc/ssl/private/iRedMail.key. Replace it with a certificate from Let's Encrypt or another certificate authority before real users connect; Postfix, Dovecot and Nginx all read those two paths.
Step 6: Add the DNS records
Other mail servers decide whether to accept your mail largely based on DNS. Create these records for the mail domain (see the iRedMail DNS guide for background):
| Type | Name | Value |
|---|---|---|
| A | mx.example.com | 203.0.113.10 |
| MX | example.com | 10 mx.example.com. |
| PTR | 203.0.113.10 | mx.example.com (set at your hosting provider) |
| TXT (SPF) | example.com | v=spf1 mx -all |
| TXT (DKIM) | dkim._domainkey.example.com | v=DKIM1; p=... |
| TXT (DMARC) | _dmarc.example.com | v=DMARC1; p=none; rua=mailto:dmarc@example.com |
The installer already created a DKIM key for the first domain. Print the public key:
amavisd showkeys
Join the quoted strings inside the parentheses into a single line without the quotes and use that as the TXT value. After the record has propagated, test it:
amavisd testkeys
The result should be pass.
Where things are on FreeBSD
FreeBSD keeps third-party software under /usr/local, so the paths differ from what Linux-oriented mail documentation shows:
| Component | Location |
|---|---|
| Postfix configuration | /usr/local/etc/postfix/ |
| Dovecot configuration | /usr/local/etc/dovecot/ |
| Nginx configuration | /usr/local/etc/nginx/ |
| PHP configuration | /usr/local/etc/php.ini |
| Amavisd configuration | /usr/local/etc/amavisd.conf |
| Fail2ban jails | /usr/local/etc/fail2ban/jail.local |
| Roundcube | /usr/local/www/roundcube |
| iRedAdmin settings | /opt/www/iredadmin/settings.py |
| iRedAPD settings | /opt/iredapd/settings.py |
| Mail log (Postfix, Amavisd, Roundcube) | /var/log/maillog |
Services are controlled with service and enabled in /etc/rc.conf. To see which services are enabled and to restart one after a configuration change:
service -e
service postfix restart
service dovecot restart
Follow mail delivery in real time while you send a test message in each direction:
tail -f /var/log/maillog
Maintenance
- Apply base system patches with
freebsd-update fetch installand package updates withpkg upgrade. Read the upgrade notes of major components first; a mail server is not the place for unattended major-version jumps. - iRedMail itself is not upgraded by re-running the installer. Each release has an upgrade tutorial on the iRedMail documentation site that lists the manual changes from the previous version.
- Back up
/var/vmail, the account database (SQL dump or LDAP export) and the DKIM keys. Without them a rebuilt server cannot take over the old mailboxes.
Frequently asked questions
Can I install iRedMail in a FreeBSD jail?
Yes. iRedMail documents a jail-based installation in a separate tutorial linked from its FreeBSD installation guide. The jail needs its own IP address and hostname, and the same fresh-system rule applies inside it.
Is 1 or 2 GB of memory enough?
Only if you remove virus scanning. ClamAV keeps its signature database in memory and is the main reason iRedMail asks for 4 GB. A server that runs out of memory during a scan starts deferring or losing mail, so size it properly rather than relying on swap.
Is the web admin panel complete in the free edition?
The open-source iRedAdmin manages domains, mailboxes and admins. More advanced features, such as managing mail aliases and spam policies from the web interface, belong to the paid iRedAdmin-Pro; in the free edition you manage those directly in the SQL or LDAP backend.
Why does mail to large providers land in spam even though everything works?
Check the PTR record, SPF, DKIM and DMARC first; a missing or mismatched PTR is the most common cause. A new IP address also has no sending reputation, so start with low volumes, and check whether the address is on a public blocklist left over from a previous owner.