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, Postﬁx and the CentOS/RHEL system must be conﬁgured 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 Postﬁx 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.
Configure Postfix As Null Client
In this example, please follow along with these steps on how to conﬁgure Postﬁx 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 conﬁguration of the Postﬁx 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. Conﬁgure the Postﬁx mail server to only relay emails from the local system.
a. Let the Postﬁx mail server listen only on the loopback interface for emails to deliver.
# postconf -e "inet_interfaces=loopback-only"
b. Change the conﬁguration 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. Conﬁgure Postﬁx 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 Postﬁx mail server from delivering any messages to local accounts.
a. Conﬁgure 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. Conﬁgure 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 conﬁguration ﬁle settings to conﬁgure Postﬁx 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 Postﬁx Settings
|DIRECTIVE||NULL CLIENT (SERVERX.EXAMPLE.COM)|
|inet_interfaces||inet_interfaces = loopback-only|
|myorigin||myorigin = desktopX.example.com|
|relayhost||relayhost = [smtpX.example.com]|
|local_transport||local_transport = error: local delivery disabled|
|mynetworks||mynetworks = 127.0.0.0/8, [::1]/128|
What are the Configuration Files for Postfix