Changelog
Setting up a mail server is tedious.
Main page to follow: https://docs.iredmail.org/install.iredmail.on.debian.ubuntu.html
Recommended to use a standalone server to host these services:
Minimum requirements of 4GB RAM for AV and spam detection services.
Created a Debian LXC to minimize resource usage. Also reminder to add SSH keys to .ssh/authorized_keys for logins.
root:~# apt update && apt upgrade root:~# apt install -y gzip dialog curl root:~# curl -L -O "https://github.com/iredmail/iRedMail/archive/refs/tags/1.7.1.tar.gz" root:~# tar xzvf 1.7.1.tar.gz
A mail domain should exist and redirect to the server. One could peruse the DNS section to understand how the hostname should be resolved; an example of /etc/hosts could be:
127.0.0.1 localhost 192.168.1.3 mail.pyuxiang.com mail myhostname
user:~$ hostname -f mail.pyuxiang.com
Execute the installer, noting to enable the nginx webserver (there is much configuration done to nginx, so might as well tag along):
root:~# cd iRedMail-1.7.1 root:~# bash iRedMail.sh
Restart the mail server host. This will also restart the nginx webserver to expose port 443. Add
Defaults are provided in iRedMail.tips (make sure to delete this after storing the credentials). Things to do:
/etc/ssl/certs/iRedMail.crt and /etc/ssl/private/iRedMail.keydkim._domainkey for DKIM./iredadminiredadmin.tmpl, roundcube.tmpl, and netdata.tmpl under nginx templates.Here's a simple DKIM parser:
#!/usr/bin/env python3 # Get DKIM record # # Example: # amavisd showkeys | ./parse_dkim.py import sys data = sys.stdin.read() data = [r.strip("\"'() ") for r in data.split("\n")[2:]] record = "".join(data) print(record)
Use mail-tester to check spammy-ness of emails. Other useful resources:
The required DNS records for mail:
| Record | Name | Value |
|---|---|---|
| A | 223.25.79.103 | |
| MX | @ | mail.pyuxiang.com. |
| TXT | @ | v=spf1 mx ~all |
| TXT | dkim._domainkey | v=DKIM1; p=MIIB... |
| TXT | _dmarc | v=DMARC1; p=quarantine; sp=reject; fo=1; adkim=s; aspf=r; rua=mailto:postmaster@pyuxiang.com |
| TXT | default._bimi | v=BIMI1;l=https://pyuxiang.com/bimi_logo.svg |
When sending mail, make sure to add a display name so that the "From" field doesn't just contain the email address.
Test authentication flow:
openssl s_client -connect mail.pyuxiang.com:587 -starttls smtp
See:
mysql vmail -- Alias fowarding (non-existent account) > INSERT INTO alias (address, DOMAIN, active) VALUES ('inbox@pyuxiang.com', 'pyuxiang.com', 1); > INSERT INTO forwardings (address, forwarding, DOMAIN, dest_domain, is_list, active) VALUES ('inbox@pyuxiang.com', 'inbox@gmail.com', 'pyuxiang.com', 'gmail.com', 1, 1); -- Alias email address (non-existent account) > INSERT INTO forwardings (address, forwarding, DOMAIN, dest_domain, is_alias, active) VALUES ('inbox@pyuxiang.com', 'hello@pyuxiang.com', 'pyuxiang.com', 'pyuxiang.com', 1, 1); -- Email forwarding + save a copy (existing account) > INSERT INTO forwardings (address, forwarding, DOMAIN, dest_domain, is_forwarding, active) VALUES ('hello@pyuxiang.com', 'inbox@gmail.com', 'pyuxiang.com', 'gmail.com', 1, 1); > INSERT INTO forwardings (address, forwarding, DOMAIN, dest_domain, is_forwarding, active) VALUES ('hello@pyuxiang.com', 'hello@pyuxiang.com', 'pyuxiang.com', 'pyuxiang.com', 1, 1);
Upgrade paths are here: https://docs.iredmail.org/iredmail.releases.html
Deploy any schema changes and other fixes first before performing a direct version upgrade of the backend software. For example, 1.7.1 -> 1.8.9 features several changes: (1) SQL schema change, (2) dovecot fixes, (3) fail2ban patches, (4) nginx configuration updates.
Dependency releases:
# Example for iRedMail v1.8.9 # iRedAPD wget https://github.com/iredmail/iRedAPD/archive/6.4.tar.gz tar zxf 6.4.tar.gz cd iRedAPD-6.4/tools/ bash upgrade_iredapd.sh # mlmmjadmin wget https://github.com/iredmail/mlmmjadmin/archive/refs/tags/3.6.3.tar.gz tar zxf 3.6.3.tar.gz cd mlmmjadmin-3.6.3/tools/ bash upgrade_mlmmjadmin.sh # iRedAdmin wget https://github.com/iredmail/iRedAdmin/archive/refs/tags/2.8.1.tar.gz tar zxf 2.8.1.tar.gz cd iRedAdmin-2.8.1/tools/ bash upgrade_iredadmin.sh # RoundCube wget https://github.com/roundcube/roundcubemail/releases/download/1.7.5/roundcubemail-1.7.5-complete.tar.gz tar xf roundcubemail-*.tar.gz cd roundcubemail-1.7.5-complete ./bin/installto.sh /opt/www/roundcubemail # netdata, note: 'stop_all_netdata' may take a while wget https://github.com/netdata/netdata/releases/download/v2.12.2/netdata-latest.gz.run chmod +x netdata-latest.gz.run ./netdata-latest.gz.run --accept touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics # Update release version to v1.8.9 vim /etc/iredmail-release