Intro
I wanted to add reply-by-email subscriptions and notifications to mix-space, so I decided to set up my own mail server.
After looking around, iRedMail seemed powerful, easy to use, and not too complicated to deploy. Let's do it!
If you want to deploy it yourself, you'll need:
- A VPS, preferably with Reverse DNS support.
- A domain name (of course)
This post is based on Ubuntu 22.04 LTS and uses the domain xxu.do as an example.
Installation
Preparing the System and Installing
- Update your packages and install the required ones:
sudo apt update
sudo apt upgrade
sudo apt install wget curl sudo tar socat bind9-utils -y
- Set mail.xxu.do as the mail domain by configuring the VPS hostname:
vim /etc/hosts
127.0.0.1 mail.xxu.do mail # Add a line; mail.xxu.do is the long hostname and mail is the short hostname
x.x.x.x mail.xxu.do mail # If your public IP is already here, change the fields after it to your hostname, then save and exit
vim /etc/hostname
mail # Change the content to mail, save and exit
reboot # Reboot to apply
hostname # You should see the short hostname mail; if you see the long hostname, it's set up incorrectly
hostname -f # You should see the long hostname mail.xxu.do; if you see the short hostname, it's set up incorrectly
- Download and install iRedMail:
wget https://github.com/iredmail/iRedMail/archive/refs/tags/1.6.8.tar.gz # As of April 1, 2024, the latest version is 1.6.8
tar -xf iRedMail.tar.gz
cd iRedMail-1.6.8 && bash iRedMail.sh
You'll now enter the graphical installer. Use Space to select, Enter to confirm the next step, and press Ctrl+C to stop the installation at any time.
1. Install, press Enter
2. Installation directory, keep the default and press Enter
3. Choose the web server; since I'm more familiar with nginx, choose nginx and press Enter
4. Choose the database; choose MariaDB (the second option), press Enter
5. Set the database password; remember it
6. Set the domain; it must not be the same as the hostname. Here: xxu.do
7. Set the admin password; remember it
8. Press y all the way through. After the installation finishes, run `reboot` to restart the system and apply the changes.
Configuring DNS Records
- Point the mail domain to your VPS, then request and install a certificate:
curl https://get.acme.sh | sh; apt install socat -y || yum install socat -y; ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
~/.acme.sh/acme.sh --issue -d mail.xxu.do --standalone -k ec-256 --force --insecure
~/.acme.sh/acme.sh --issue -d mail.xxu.do --webroot /var/www/html
~/.acme.sh/acme.sh --installcert -d mail.xxu.do --key-file /etc/ssl/private/iRedMail.key --fullchain-file /etc/ssl/certs/iRedMail.crt
service postfix reload;service dovecot reload;service nginx reload # Reload services
- Disable iRedMail's greylisting (I'm not sure what effect it has; I just followed the tutorial):
vi /opt/iredapd/settings.py
# Remove "greylisting" and keep the formatting consistent; or delete the whole line and replace it with the line below
plugins = ["reject_null_sender", "wblist_rdns", "reject_sender_login_mismatch", "greylisting", "throttle", "amavisd_wblist", "sql_alias_access_policy"]
Set up PTR reverse DNS: go to your VPS control panel, set the PTR record to the mail domain (mail.xxu.do here), and verify with
nslookup x.x.x.x(your server IP).Add the DNS records:
vi /root/iRedMail-1.6.8/iRedMail.tips
# Find the part similar to the one below, copy it, remove all quotes and spaces, and concatenate it into one continuous string.

You should get something like the code below. Paste it into the Content field of the dkim._domainkey record:
v=DKIM1;p=MIIBIjANBgkqhkiG9w0BAQEFAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
| Type | Name | Content |
|---|---|---|
| MX | xxu.do | mail.xxu.do |
| TXT | xxu.do | v=spf1 mx ~all |
| TXT | dkim._domainkey | See above, e.g. v=DKIM1;p=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| TXT | _dmarc | v=DMARC1; p=none; pct=100; rua=mailto:dmarc@xxu.do |
Configuring iRedMail
You can now visit the following pages:
https://mail.xxu.do/mail — Email login page
https://mail.xxu.do/netdata — Server status monitoring
https://mail.xxu.do/iredadmin — Mail server admin panel
Account: postmaster@your domain; here it is postmaster@xxu.do
Password: the password you set during installation
The above info can also be viewed in /root/iRedMail-1.6.8/iRedMail.tips
To add users, log in to the mail server admin panel and add them where shown below.

Add user
Testing the Mail Server
mail-tester
- Go to https://www.mail-tester.com and get a test email address.
- Log in to the mailbox with the admin account (postmaster@xxu.do), pick any of the three emails the system sent, and send it to the test email address.
- Go back to https://www.mail-tester.com and click Test.
Unsurprisingly, it got a perfect 10/10.
Gmail Test
I tried sending an email to my Gmail account, but it went to Spam. After manually marking it as not spam, subsequent emails I sent to others were delivered normally.
Email Client Support
| Protocol | Address | Port & Secure Port |
|---|---|---|
| IMAP | xxu.do | 143,993 |
| POP3 | xxu.do | 110,995 |
| SMTP | xxu.do | 25 (must be open), 587 |
Outro
After installing iRedMail, I couldn't deploy any other services. After troubleshooting, I found that nftables was probably installed by default. I edited the rules in vi etc/nftables.conf, restarted the service with systemctl restart nftables, and it was fine.