How to install Postfix on CentOS Stream 10 and configure an SMTP server

Postfix Mail Server
Postfix is a popular mail server (MTA – Mail Transfer Agent) designed for sending, receiving, and routing emails in Linux- and Unix-based systems. Developed as a replacement for Sendmail, it offers high performance, flexibility, and security. The main features of Postfix include support for various authentication mechanisms, spam filtering, protection against DDoS attacks, and the ability to work with multiple domains. It is widely used in corporate and cloud environments due to its high reliability and ease of configuration.
Main Advantages of the Postfix Mail Server
- Postfix efficiently processes thousands of emails per minute using multi-threaded processes and optimized queues.
- Support for TLS encryption, spam protection using SPF, DKIM, and DMARC, as well as built-in mechanisms to prevent email spoofing.
- Ability to integrate with various databases (MySQL, PostgreSQL) and support for LDAP and SASL for user authentication.
- Postfix configuration files are logical and easy to understand, and built-in utilities simplify diagnostics and mail server management.
Postfix is widely used in various scenarios:
- Corporate mail servers – ensuring internal and external email communication.
- SMTP gateways – filtering, protecting, and routing emails for other servers.
- Marketing platforms – mass email distribution with high delivery rates.
- Web hosting – working alongside web servers and engines to send notifications and emails to users.
Installing Postfix on CentOS Stream 10
First, ensure that the system is up to date:
1. Update system packages
dnf update -y
2. Then install Postfix and the necessary dependencies
dnf install -y postfix mailx cyrus-sasl cyrus-sasl-plain
3. Disable the old mail agent, such as Sendmail (if installed), and enable Postfix:
systemctl stop sendmail
systemctl disable sendmail
# Enable Postfix
systemctl enable postfix
systemctl start postfix
Configuring Postfix for SMTP
To configure SMTP, you need to edit the main configuration file /etc/postfix/main.cf
:
1. Open the file in the nano editor
nano /etc/postfix/main.cf
2. Find and modify / add the following lines:
# Specify the server domain
myhostname = mail.example.com
# Allow operation with the local network and external clients
inet_interfaces = all
# Allow receiving mail only for specified domains
mydestination = $myhostname, localhost.$mydomain, localhost
# Configure SMTP authentication
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination
# Enable TLS encryption
smtpd_tls_security_level = may
smtpd_tls_cert_file = /etc/ssl/certs/postfix.pem
smtpd_tls_key_file = /etc/ssl/private/postfix.key
3. After making changes, save the file and restart Postfix:
systemctl restart postfix
Checking Mail Server Operation
To ensure that Postfix is working correctly, use the command:
systemctl status postfix
You can also send a test email:
# Send a test email to a local user
echo "Postfix Test" | mail -s "Test" user@example.com
You can view the server logs using:
# View Postfix logs
journalctl -u postfix -n 50
After completing all the steps, your Postfix-based SMTP server will be configured and ready to send and receive emails.
Latest news
Discount on all Ukrainian domains until 10/21/2022!
Dear users! For a whole week -15% discount for registration of all Ukrainian domains using the promo code defendersday22!Increase in price of a number of Ukrainian domains UA ccTLD!
Dear users! From October 1, 2022, we are waiting for a rise in price in a number of Ukrainian domains - in.ua, od.ua, mk.ua!Important changes in some Ukrainian domains!
Dear users! In some Ukrainian domain zones, the Redemption period for domains has been increased from 30 to 60 days.Rise in price of dedicated IPv4 in Germany!
Dear users! In Germany, additional dedicated IP addresses (IPv4) and IP networks have risen significantly.Latest Blog Posts