How to Configure a Postfix Null Client Step by Step

This tutorial explains how to configure a Postfix null client in RHEL/CentOS which forward all mail to a central mail server. Learn what a null client is in Postfix and how to setup it in RHEL/CentOS step by step with practical examples.

For this tutorial I assume that you familiar with basic concepts and terminology of email system. If you are interested in learning the essential of email system, check this tutorial.

How Email Works Step by Step Explained

It explains how email system works in detail including terminology such as MTA, MSA, DA, mail clients etc.

RHCE Objective

This tutorial explains following RHCE Objective.

Configure a system to forward all email to a central mail server.

Practice LAB Setup

For practice lab, we need at least two systems. In first system, we will configure a null client which forwards all email to a central mail server. In second system, we will configure a central mail server which accepts mails from null client.

I have already explained how to setup a RHCE practice lab with virtual systems in following tutorial.

RHCE Practice LAB Setup

From this practice lab, I will use system for central mail server and for null client. You may use this practice lab or create your own lab to follow the exercises explained in this tutorial.

If you are using your own lab; make sure it meets with following requirements.

It contains at least two systems. Both systems must be connected with each other and should be able to access each other via hostname.

lab setup for practice

Postfix mail server

Staring from version 7.0, the Postfix is the default mail server in RHEL/CentOS. Unless mail server is manually skipped through the software selection process during the installation, Postfix mail server should be already installed in system. The postfix package provides Postfix mail server. For this tutorial I assume that postfix package is already installed in both systems. If it is not installed, install it first with following command.

#yum -y install postfix

The main configuration file of Postfix mail server is /etc/postfix/ All the Postfix parameters are stored and configured in this file. In order to configure the Postfix mail server, we have to change the appropriate parameters in this file.

This file can be edited in two ways: by using a text editor such as vim or using the command postconf.

Main configuration file contains several parameters to control the various operations of Postfix mail server. Unless you are an experienced linux administrator, you should not edit this file directly.

The postconf command provides an easy way to edit this file. It allows us to perform following actions directly from command prompt without opening the main configuration file.

  • Query and display all settings or individual setting
  • Modify and update an existing setting
  • Add a new setting at the end of the file

To perform above actions following commands are use.

Command Description
postconf Query and display all settings
postconf [parameter] [parameter] [parameter…] Query and display an individual setting or multiple settings. Use white space to separate the parameters
postconf –e ‘[parameter] [parameter value]’ If parameter exists, update it otherwise add a new parameter in the end of the file
postconf –n Display the parameters which are newly added or updated

Understanding Essential Postfix settings

The main configuration file contains more than 800 hundred settings. To view all settings, you can use the postconf command without any option.


The wc –l command counts the number of lines from supplied source. If we redirect the output of the postconf command in this command, it will tell us how many lines (settings) are there.

Learning all these settings are neither required nor recommended for RHCE exam purpose. For exam, you should focus only following settings which are used to setup a null client and a functional central mail server.


This setting defines the network interfaces on which Postfix listens for messages. If this setting is set to loopback-only, Postfix will listen only from local system on loopback interface. If this setting is set to all, Postfix will listen from all systems on all network interfaces.


This setting defines how the sender address should be written in email. There are two ways to write it; with hostname and without hostname.

If a user Alex sends a mail from a system which hostname and domain name are set to dev1 and respectively, the sender address will appear in message as following.

With hostname: - [email protected]

Without hostname: - [email protected]

Both addresses are correct and can be used in sender address. Usually first type of address is used in testing environment while second type of address is used in real world.

In real world, usually email recipients do not care from which system the message is arrived. They only care about the user who sent the mail and the domain from which the mail is arrived.

To use sender address with hostname, you can use value $myhostname. To use sender address without hostname, you can use value $mydomain.


This setting defines the location where Postfix should send all outgoing messages. If a central mail server is configured in network, its name will be used in this setting in other systems of network. In central mail server, this setting is used to define the addresses of SMTP hosts on Internet where it should forward the outgoing messages.

By default Postfix do a DNS MX record lookup for what you specify in this setting. To instruct Postfix to avoid a DNS lookup for the specified hostname, put hostname in square brackets. If hostname is specified in square brackets, instead of DNS lookup, Postfix uses hosts file to translate the hostname. To disable DNS lookup completely, use next setting.


If this setting is set to yes, Postfix will not perform any DNS lookup to resolve the hostname. If this setting is enabled, there is no need to put hostname in square brackets.


This setting defines the domains which emails Postfix accepts. Postfix accepts only incoming mails which are intended for the domains listed in this setting. If this setting is set to blank, postfix will not accept any incoming mail.


This setting defines the local program which postfix uses to deliver the received mails. If host does not accept any incoming mail, you can set a descriptive error message such as “error: local delivery disabled.” in this setting.


This setting defines the version of IP protocol which Postfix uses. By default Postfix uses both versions (IPv4 and IPv6) for its operations. If your server does not use IPv6, you can set it to IPv4.


This setting defines the list of networks that are allowed to use this email server. This setting provides a basic protection against email abuse. This setting limits Postfix to accept messages only from your trusty networks.

Following table summarizes the settings which require in configuring a null client and a functional email server.

Setting Null Client Functional Email Server
inet_interfaces loopback-only all
myorigin $hostname keep default /no change
relayhost keep default / no change
mydestination keep it blank,
local_transport error: local delivery disabled keep default / no change
inet_protocols ipv4 ipv4
mynetworks keep default / no change
disable_dns_lookups yes yes

In my practice lab, the FQDN (Fully Qualified Domain Name) hostname of system1 where I will setup a central email is If hostname in your system is set to different, please use that name instead of

Before we change above settings, let’s check their default values with following command.

#postconf inet_interfaces myorigin relayhost mydestination local_transport inet_protocols mynetworks disable_dns_lookups
postconf default setting

Setting up a central mail server

Access root shell in system1 and run following commands.

#postconf –e “inet_interfaces = all”
#postconf –e “mydestination =,”
#postconf –e “inet_protocols = ipv4”
#postconf –e “disable_dns_lookups = yes”

postfix server configuration

Postfix reads configuration file when it starts. Whatever change we made in configuration file will not apply until postfix service is restarted.

Run following commands to check the configuration file and restart the postfix service.

#postfix check
#systemctl restart postfix

postfix service restart

Default firewall configuration does not allow Postfix to receive incoming messages. Postfix uses smtp service to exchange messages with other email servers and hosts. In order to allow Postfix traffic, we have to add an allow rule in firewall for smtp service.

#firewall-cmd --add-service smtp --permanent
#firewall-cmd --reload

add rule in firewall service

That’s all settings we need to setup a functional Postfix email server which accepts emails from remote clients.

Postfix null client setup

Access root shell in system2 and run following commands

#postconf –e ‘relayhost =’
#postconf –e ‘inet_interfaces=loopback-only’
#postconf –e ‘inet_protocols=ipv4’
#postconf –e ‘mynetworks=’
#postconf –e ‘myorigin=$myhostname’
#postconf –e ‘mydestination=’
#postconf –e ‘disable_dns_lookups=yes’
#postconf –e ‘local_transport=error: local delivery disabled’

Above commands will configure Postfix as a null client. Once it’s done, run following commands to check the configuration and restart the postfix service.

#postconf check
#systemctl restart postfix

postfix null client setup

Testing postfix null client setup

To test postfix null client setup, compose a simple mail with subject line “test” and send it to user root of system1. To compose and send a mail directly from command prompt, type following and press enter.

#mail –s test [email protected] <.

send test mail

On system1, use mail command to view the mails. You should see the test mail that has been sent from null client.

verify mail received in server


The process of setting up a null client is simple and straightforward. Usually there should be no issue in it, but due some reason if your configuration is not working, following tips will help you in finding and fixing the problem.

Incorrect setting in configuration file

Adding an unrecognized setting or updating a setting incorrectly will stop Postfix from starting. To confirm that all settings are configured correctly, you can use postfix check command. This command checks all settings from configuration file. If they are configured correctly it returns nothing but if any setting is configured incorrectly, it prints that setting on terminal.

postfix check

log files

While debugging a service, log files are the most helpful resources. The Postfix uses /var/log/maillog file to store its logs. By examining this file, you can figure out whether your message was delivered successfully or not and if it was not delivered, you will often find an explanation why it was not delivered.

To examine this file, use following command

#tail –f /var/log/maillog

postfix mail log

The postqueue command

Finally you can use postqueue command to view and flush the messages which are still waiting for delivery. To view the delivery queue, use postqueue –p command. To flush the delivery queue, use postqueue –f command.

That’s all for this tutorial. If you have any query, feedback or suggestion regarding this tutorial, please mail me. If you like this tutorial, please don’t forget to share it with friends.

ComputerNetworkingNotes Linux Tutorials How to Configure a Postfix Null Client Step by Step