Need to migrate your e-mails to a new server? Free and paid versions of our online tool available.
Hero Image

Install and Configure Postfix on RHEL 9

Install and Configure Postfix on RHEL 9

Step 1 – Install

dnf install -y postfix mailx
systemctl enable --now postfix

Step 2 – /etc/postfix/main.cf

myhostname  = mail.example.com
mydomain    = example.com
myorigin    = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks  = 127.0.0.0/8 [::1]/128

# TLS
smtpd_tls_cert_file = /etc/ssl/certs/mail.example.com.crt
smtpd_tls_key_file  = /etc/ssl/private/mail.example.com.key
smtpd_tls_security_level = may
smtp_tls_security_level  = may

# Mailbox
home_mailbox = Maildir/
message_size_limit = 52428800

# Anti-spam
smtpd_helo_required = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

Step 3 – Reload and test

postfix check
systemctl reload postfix 2>/dev/null || rcctl reload postfix
echo "Test" | mail -s "Test" [email protected]