Share your love
Install and Configure Postfix Mail Server on AlmaLinux 8

In this guide from the Orcacore website, we want to teach you how to Install and Configure Postfix Mail Server on AlmaLinux 8.
Postfix is a state-of-the-art message transport agent (MTA), aka SMTP server, which serves two purposes:
- It’s responsible for transporting email messages from a mail client/mail user agent (MUA) to a remote SMTP server.
- It’s also used to accept emails from other SMTP servers.
Postfix was built by Wietse Venema, who is a Unix and security expert. It’s easy to use and is designed with security and modularity in mind, with each module running at the lowest possible privilege level required to get the job done. Postfix integrates tightly with Unix/Linux and does not provide functionalities that Unix/Linux already provides. It’s reliable in both simple and stressful conditions.
Postfix was originally designed as a replacement for Sendmail, the traditional SMTP server on Unix. In comparison, Postfix is more secure and easier to configure. It is compatible with Sendmail, so if you uninstall Sendmail and replace it with Postfix, your existing scripts and programs will continue to work seamlessly.
Table of Contents
Steps To Install and Configure Postfix Mail Server on AlmaLinux 8
To install Postfix on your server, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on the Initial Server Setup with AlmaLinux 8.
Now follow the steps below to complete this guide.
1. Install Postfix on AlmaLinux 8
First, you need to update your local package index with the following command:
sudo dnf update -y
Then, run the command below to check whether Sendmail is installed or not:
rpm -qa | grep sendmail
If you didn’t get any output, that means you don’t have Sendmail installed, and you can keep going.
If you have Sendmail installed on your server, you need to remove it with the following command:
sudo dnf remove sendmail* -y
At this point, you can check whether you have Postfix installed on your server or not:
rpm -qa | grep postfix
Next, if you don’t have it installed on your server, use the command below to install Postfix on AlmaLinux 8:
sudo dnf install postfix -y
2. Configure Postfix on AlmaLinux 8
At this point, you need to make some configuration changes to the Postfix main configuration file.
First, open the file with your favorite text editor like Vi Editor or Nano Editor:
sudo vi /etc/postfix/main.cf
At the file, uncomment the myhostname line and set it to your hostname:
myhostname = your-hostname
Uncomment and set the domain name on the line below:
mydomain = your-domain-name
Also, uncomment the line below:
myorigin = $mydomain
Uncomment and set IPv4 at the following line:
inet_interfaces = all
Set the line below to all:
inet_protocols = all
Comment on the following line:
#mydestination = $myhostname, localhost.$mydomain, localhost,
Uncomment and add the IP range at the following line:
mynetworks = 192.168.1.0/24, 127.0.0.0/8
Finally, uncomment the line below:
home_mailbox = Maildir/
When you are done, save and close the file.
At this point, you need to start and enable your Postfix Mail server with the following commands:
# sudo systemctl enable postfix
# sudo systemctl restart postfix
Verify that your Postfix service is active and running on AlmaLinux 8:
sudo systemctl status postfix

3. Testing Postfix with Telnet
At this point, you need to create a new user for testing. To do this, run the command below:
sudo useradd postfixtester
Add a password for your user:
sudo passwd postfixtester
When you are done, you will get the following output:
Output
passwd: all authentication tokens updated successfully.
After adding the user, let’s check the server access using telnet. If you don’t have telnet installed on your server, use the command below to install telnet on AlmaLinux 8:
sudo dnf install telnet -y
Then, run the following command:
telnet localhost smtp
Once you have successfully done the configuration, you will get the following output:

Start your transaction by writing the following command:
ehlo localhost
250-hostname
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
Once you get 250 DSN, you can send mail.
Finally! You have Postfix installed, and emails are getting sent! You are all set to use your server as your private SMTP server to send emails.
For more information, you can visit the Postfix Documentation page.
Conclusion
At this point, you have learned to Install and Configure Postfix Mail Server on AlmaLinux 8. Postfix sets up a reliable mail server for sending and receiving emails. It is a good choice for managing email services on your server.
Hope you enjoy it. You may be interested in these articles too:
Install HomeBrew on AlmaLinux 8
Install and Use PostgreSQL on AlmaLinux 8