Postfix is an efficient Mail Transfer Agent used for routing and sending receiving emails which is available as OpenSource software. It is the most well-known email server used in different Linux distributions. This is actually the replacement of an old Sendmail MTA that is pre-installed on the latest Rocky Linux versions as well. You may need to install the postfix mail server on your system. Today, we will explain the installation process of the postfix server on the Rocky Linux 8 system using the Terminal.
All commands will run on the terminal application in this article. To access the terminal, click on the Activities option located at the top left corner of Rocky Linux 8 environment, and then click on the Terminal from the left pane of your desktop.
Installation of Postfix on Rocky Linux 8
To install the Postfix on Rocky Linux 8, you need to follow the following steps:
First, you need to remove the Sendmail from your system. Therefore, you can easily check that Sendmail is pre-installed on your system or not by using the following command:
$ rpm -qa | grep sendmail
If it is already installed, then you will see the installed version will display on the terminal. Otherwise, it will show any output on the screen. In this situation, you can leave this step.
You can remove the Sendmail by typing the following command on the terminal:
$ yum remove sendmail*
$ dnf remove sendmail
After removing the Sendmail, you will update your system by executing the following command:
$ dnf update
Once you verify that there is no other MTA is running on your system then, you will install the postfix server by typing the following command:
$ sudo dnf install postfix
The confirmation prompt will interrupt the installation and ask for the confirmation to install the postfix server on the CentOS system. Press ‘y’ in case of yes and then, hit ‘Enter’ key to proceed with the further installation process.
Once the installation of the Postfix server is completed, you can verify that either it is now installed on your system or not by running the following command on the terminal:
$ rpm -qa|grep postfix
The following output should display on your system:
Enable Postfix Service
Now, the postfix server has been installed on your system. Enable and restart the Postfix services by running the below-mentioned commands:
$ systemctl enable postfix
After executing the above command, it will ask you to enter the login password for authentication. Enter the password and click on the ‘Authenticate’ button. You will see the following output with symlink creation on the Terminal window:
Now, start the postfix services by running the following command:
Again, you need to authenticate the user. Enter the password and then hit on the ‘Authenticate’ button.
After that run the following command to check the postfix services status:
$ systemctl status postfix
The following output will show on the Terminal window:
As you can see in the above image the Postfix services are running on this system.
Next, configure the postfix mail server to send emails to your local server. To exit from the current window press ‘Ctrl + c’.
Install Email Client mailx
Before start the configuration of the postfix server, you need to first install mailx email client on the system by typing the following command:
$ sudo dnf install mailx
Confirm the installation of the mailx package by pressing ‘y’ and then hit ‘Enter’. Now the installation of mailx will be started and once completed, you will be notified as shown in the following screenshot.
Now, you can easily send emails to your local email server. For example, we are sending an email subject test mail to the recipient admin. For this purpose, we have typed the below-mentioned command on the Terminal:
$ mail kbuzdar
The term ‘mail’ in the above command is referring to a client and the recipient is ‘kbuzdar’ here. The ‘.’ sign at the end of the emails sends the signal to the mail client that the email is ended now. Now, it will be sent to the postfix server for email delivery.
To check whether the email reached its destination or not, log in as the root user from the recipient side, and then write ‘mail’ on the Terminal.
The following list of emails will display on the terminal including the last email that you have sent will show at the end.
That’s all about the Postfix server installation on Rocky Linux 8 using the command line. Moreover, you have seen how to send emails to the local server via the Postfix services. You can send emails to a particular domain by changing the name of your machine. I hope you liked this article and it may help you in the future.