To install packages on RHEL 8 / CentOS 8 use yum command.
Install postfix package by using the following command:
yum install postfix
To enable and start systemd service enter:
systemctl enable postfix ; systemctl start postfix
To verify the service is working we can install the mailx package:
# dnf install mailx
As a normal user (named foo on the lab machine) we write a mail to the admin, in this example we request for more (what else?) disk space:
$ mail root Subject: quota rise request Dear admin, Please increase my disk quota with 1 GB. Thanks, foo . EOT
Where mail is the client we use, and root is the recipient. The last line containing only a dot will signal the mail client this is the end of our mail, which will be handed to postfix for delivery.
To verify the mail is arrived, log in as root (the recipient), and type mail. You should see the list of your mails, with this only item on the list sent in the last step:
# mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 foo@rhel8lab Mon Nov 26 19:05 20/634 "quota rise request" &
Where N is “new”, 1 is the ID of the message, foo@rhel8lab is the sender (username@hostname), delivery time and the subject can also be seen. By typing the message ID, in this case 1 and hitting enter you can read your local mail, verifying the mail delivery system is working as intended.
Source: https://linuxconfig.org/how-to-install-postfix-on-redhat-8