How to Configure Postfix Null Client

Postfix is a powerful but easy-to-configure mail server. It is the default mail server in Red Hat Enterprise Linux 7. Postfix is provided by the postfix RPM package. It is a modular program made up of several cooperating programs. Its components are controlled by the master process. The main configuration file of the postfix mail server is /etc/postfix/main.cf.

Postfix Null Client Configuration

Remember, to act as a null client, Postfix and the CentOS/RHEL system must be configured so that the following things are true:

  • The sendmail command and programs that use it forward all emails to an existing outbound mail relay for delivery
  • The local Postfix service does not accept local delivery for any email messages
  • Users may run mail clients on the null client to read and send emails.

The following diagram illustrates how a null client setup works. For sending mails, the null client on **serverX **delivers all messages to the corporate SMTP mail server smtpX.example.com.

Postfix Null Client Communication

Note: A complete overview of all settings that are adjustable in /etc/postfix/main.cf and their explanations can be found in the postconf(5) man page. To access this man page, use the man 5 postconf command. Omitting the 5 will display the man page for the postconf command rather than the configuration guide.

Configure Postfix As Null Client

In this example, please follow along with these steps on how to configure Postfix on **serverX.example.**com as a null client that uses the **smtpX.example.**com mail server as a relay host. All mails passed on by the local null client have their sender address domain rewritten to desktopX.example.com.

Adjust the configuration of the Postfix mail server on your serverX system to act as a null client that forwards all messages to the corporate mail server on smtpX.example.com, which is responsible for the desktopX.example.com domain

1. Adjust the relayhost directive to point to the corporate mail server. The host name of the corporate mail server needs to be enclosed in square brackets to prevent an MX record lookup with the DNS server.

# postconf -e "relayhost=[smtpX.example.com]"

2. Configure the Postfix mail server to only relay emails from the local system. a. Let the Postfix mail server listen only on the loopback interface for emails to deliver.

# postconf -e "inet_interfaces=loopback-only"

b. Change the configuration of the null client so that mails originating from the 127.0.0.0/8 IPv4 network and the [::1]/128 IPv6 network are forwarded to the relay host by the local null client.

# postconf -e "mynetworks=127.0.0.0/8 [::1]/128"

3. Configure Postfix so all outgoing mails have their sender domain rewritten to the company domain desktopX.example.com.

# postconf -e "myorigin=desktopX.example.com"

4. Prohibit the Postfix mail server from delivering any messages to local accounts. a. Configure the null client to not act as an endpoint for any mail domain. Mails, where the recipient is a local email account, are not accepted for local delivery. The mydestination option needs to be set to an empty value to achieve this.

# postconf -e "mydestination="

b. Configure the local null client to not sort any mails into mailboxes on the local system. Local email delivery is turned off.

# postconf -e "local_transport=error: local delivery disabled"

5. Restart the local postfix null client.

# systemctl restart postfix

The following table shows a summary of the /etc/postfix/main.cf configuration file settings to configure Postfix on serverX.example.com as a null client that uses the smtpX.example.com mail server as a relay host. All messages that are passed on by the local null client have their sender address domain rewritten to desktopX.example.com.

Null Client Postfix Settings

DIRECTIVE NULL CLIENT (SERVERX.EXAMPLE.COM)
inet_interfaces inet_interfaces = loopback-only
myorigin myorigin = desktopX.example.com
relayhost relayhost = [smtpX.example.com]
mydestination mydestination =
local_transport local_transport = error: local delivery disabled
mynetworks mynetworks = 127.0.0.0/8, [::1]/128