Setting up Postfix on AlmaLinux/Rocky Linux follows the same core concepts as other distributions, with distribution-specific package names and firewall/SELinux considerations covered here.
Step 1 — Install Postfix
sudo dnf install postfix -y
Postfix is typically pre-installed as the default MTA on AlmaLinux/Rocky Linux, but verify and install explicitly if needed.
Step 2 — Install Dovecot for IMAP/POP3
sudo dnf install dovecot -y
Step 3 — Configure Postfix's Basic Settings
sudo nano /etc/postfix/main.cf
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
See How to Install and Configure Postfix as a Mail Transfer Agent for the complete general configuration — identical concepts and most configuration directives apply regardless of distribution.
Step 4 — Start and Enable Services
sudo systemctl enable --now postfix dovecot
Step 5 — Configure firewalld for Mail Services
sudo firewall-cmd --permanent --add-service=smtp
sudo firewall-cmd --permanent --add-service=imap
sudo firewall-cmd --permanent --add-service=imaps
sudo firewall-cmd --permanent --add-service=pop3s
sudo firewall-cmd --reload
firewalld includes predefined service definitions for common mail protocols, simpler than manually specifying each port individually.
SELinux Considerations for Mail Services
sudo ausearch -m avc -ts recent | grep postfix
Standard Postfix/Dovecot operation typically works correctly with default SELinux policy — but if you customize mail storage locations or add virtual domain database lookups, check for and address any resulting denials as covered in How to Configure SELinux Policies for a Custom Application.
Setting Up SPF, DKIM, and DMARC
See How to Configure SPF, DKIM, and DMARC (Complete Guide) — this configuration happens at the DNS level and application configuration level, identical regardless of underlying OS distribution.
Installing OpenDKIM
sudo dnf install epel-release -y
sudo dnf install opendkim opendkim-tools -y
OpenDKIM requires EPEL on AlmaLinux/Rocky Linux (see Understanding EPEL and Additional Repositories for AlmaLinux/Rocky Linux) — not available in the base repositories.
Testing Mail Server Functionality
echo "Test email body" | mail -s "Test Subject" [email protected]
Setting Up Webmail (Roundcube)
See How to Set Up Webmail (Roundcube) for Your Mail Server — the setup process is essentially identical; only PHP/web server installation commands differ per the distribution-specific guides referenced elsewhere in this Knowledge Base.
Common Errors
Mail delivery working locally but SELinux blocking specific mail operations — check ausearch for AVC denials specifically related to postfix or dovecot process names; address via appropriate boolean or custom policy as needed.
Continue Reading
- How to Install and Configure Postfix as a Mail Transfer Agent
- How to Configure SPF, DKIM, and DMARC (Complete Guide)
- How to Configure firewalld on AlmaLinux/Rocky Linux
Browse more articles in AlmaLinux & Rocky Linux.