Configuring Postfix to Relay Mail to Local Exchange Mail Server in RHEL/ CentOS 7

1. Overview


On your Linux server or virtual dedicated server may have installed some applications that need an email server solutions to send email notification to user mailbox in your local Microsoft Exchange server or hosted Microsoft Exchange server. For this case, we can use Postfix as email server solution to achieve this objective.

In this tutorial, we will install and configure Postfix to be the send-only SMTP Email server running on local CentOS 7 Linux box, so that it can be used to send emails by local applications by relaying the email to local Microsoft Exchange server or MS Exchange server hosting.

2. Prerequisites


In this tutorial how to configure Postfix to relay Email to email to local Microsoft Exchange server or hosted Microsoft Exchange server, it is supposed that:

a. You have already install RHEL/CentOS 7 Linux server up and running. In case that you don’t, you would probably like to read this link. Minimal RHEL/CentOS 7 Installation With Logical Volume Manager (LVM).
b. You have already done the initial server setup. Please refer to this link Minimal RHEL/CentOS 7 Initial Server Setup.

3. System Architecture Diagram


We will configure Postfix Email server solutions to work as a null client as shown in following diagram. A null client, in Postfix, is a computer that can only send mail. It receives no mail from the network, and it does not deliver any mail locally. The null client will relay all mail with domain name “” to Ms Exchange servers located within the same network or to the hosted Microsoft Exchange server.

4. Configure Postfix to Work as a Null Client


First of all, we need to enable and start postfix service by execute the following commands.

# systemctl enable postfix
# systemctl start postfix

To configure Postfix to work as null client, edit file /etc/postfix/ as the following.

# vim /etc/postfix/
myhostname = vkcent-web01.techspacekh.local
mydomain = techspacekh.local
myorigin = $mydomain
inet_interfaces = loopback-only
inet_protocols = ipv4
mydestination =
local_transport = error: local delivery disabled
mynetworks =
relayhost =

The relayhost option instructs Postfix to forward any email which the destination domain is not  “techspacekh.local” to local Ms Echange server with IP address of

The loopback-only option instruction Postfix to not any accept email from any network. The Postfix null client will forward only the messages that originate from the network to local Ms Echange server.

The local_transport option instruction Postfix Email server solution to prevent the local null client from sorting any mail into mailboxes.  Also, we need to disable local mail delivery by not specifying any option for mydestination parameter.

Now we need to restart Postfix service.

# systemctl restart postfix

We can test send an email to any user located in Ms Exchange server.

# mail
Subject: Hi Vannath
How are you?

we can check Postfix Email server solution log in file /var/log/maillog and we should  be able to see something as below.

Jun 10 08:37:49 vkcent-web01 postfix/pickup[22035]: CE12860026D: uid=0 from=<root>
Jun 10 08:37:49 vkcent-web01 postfix/cleanup[28718]: CE12860026D: message-id=<20170610013749.CE12860026D@vkcent-web01.techspacekh.local>
Jun 10 08:37:49 vkcent-web01 postfix/qmgr[22036]: CE12860026D: from=<root@techspacekh.local>, size=466, nrcpt=1 (queue active)
Jun 10 08:37:50 vkcent-web01 postfix/smtp[28720]: CE12860026D: to=<>, relay=[]:25, delay=0.2, delays=0.01/0.01/0/0.18, dsn=2.6.0, status=sent (250 2.6.0 <20170610013749.CE12860026D@vkcent-web01.techspacekh.local> [InternalId=27702539060351,] 1699 bytes in 0.111, 14.884 KB/sec Queued mail for delivery)
Jun 10 08:37:50 vkcent-web01 postfix/qmgr[22036]: CE12860026D: removed

7. Conclusion


That’s all about how to set up a send-only email server using Postfix Email server solution in RHEL/ CentOS 7 Linux server locally or virtual dedicated server to relay email to local Ms Exchange Email server or MS Exchange server hosting. Hopefully, you can find this instruction informative. If you have any questions or suggestions you can always leave your comments below. I will try all of my best to review and reply them.