How to Set Up a Mail Server (Postfix) on AlmaLinux/Rocky Linux

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

Browse more articles in AlmaLinux & Rocky Linux.

  • postfix almalinux, mail server rocky linux, dovecot rhel setup, firewalld mail services
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

AlmaLinux vs Rocky Linux vs CentOS: What Happened to CentOS?

If you're choosing a RHEL-compatible Linux distribution for your VPS, understanding the CentOS...

How to Get Started with AlmaLinux/Rocky Linux on a VPS

This guide covers the essential first steps after deploying a new AlmaLinux or Rocky Linux VPS...

How to Use dnf: The Package Manager for AlmaLinux & Rocky Linux

dnf (Dandified YUM) is the package manager for AlmaLinux, Rocky Linux, and other RHEL-family...

How to Configure firewalld on AlmaLinux/Rocky Linux

firewalld is the default firewall management tool on AlmaLinux and Rocky Linux, using a...

How to Install Nginx on AlmaLinux/Rocky Linux

This guide covers installing and configuring Nginx on AlmaLinux or Rocky Linux, including the...