Postfix is a common mail server, many large distributions are shipped with Postfix installed by default. The default configuration allows local mailing only, but that in itself is very useful on a machine used by many users, and even if there is no such traffic, many services dump their reports and messages into e-mails, which is delivered to the root user locally, so the sysadmin will be noticed on any events of interest when he/she logs in and switches to root user.

A simple example would be scheduled cron jobs: any output not redirected from the output of a script running from cron will be wrapped to an e-mail and will be delivered to root's mailbox, so the administrator does not even have to make any effort to have the reports of the nightly backup jobs at hand.

While this standalone mode is certainly a nice service as it is, postfix is a full-fledged mail server, capable of receiving, forwarding, relaying, filtering of e-mails, it basically have every feature we need for a mail server.

In this tutorial you will learn:
  • How to install postfix on RHEL 8 / CentOS 8
  • How to verify the working service with standalone functionality.
Reading local mail delivered by Postfix.
Reading local mail delivered by Postfix.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL 8 / CentOS 8
Software postfix-3.3.1-4, mailx-12.5-28
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to install postfix mail server on RHEL 8 / CentOS 8 step by step instructions


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


If you didn't choose the mail server packages when installing the system, postfix will not be present by default. To install it we will use dnf, but to do that, Subscription Management repositories must be enabled on the system to reach the software sources we'll install from.

  1. To install packages on RHEL 8 / CentOS 8 use dnf command. Install postfix package by using the following command:
    # dnf install postfix
  2. To enable and start systemd service enter:
    systemctl enable postfix ; systemctl start postfix
  3. To verify the service is working we can install the mailx package:
    # dnf install mailx
  4. 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.

  5. 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.

ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.