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.
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 “techspacekh.com” 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/main.cf as the following.
# vim /etc/postfix/main.cf 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 = 127.0.0.0/8 relayhost = 10.0.0.2
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 10.0.0.2.
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
127.0.0.0/8 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 firstname.lastname@example.org Subject: Hi Vannath How are you? . EOT
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: CE12860026D: uid=0 from=<root> Jun 10 08:37:49 vkcent-web01 postfix/cleanup: CE12860026D: message-id=<20170610013749.CE12860026D@vkcent-web01.techspacekh.local> Jun 10 08:37:49 vkcent-web01 postfix/qmgr: CE12860026D: from=<email@example.com>, size=466, nrcpt=1 (queue active) Jun 10 08:37:50 vkcent-web01 postfix/smtp: CE12860026D: to=<firstname.lastname@example.org>, relay=10.0.0.2[10.0.0.2]: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, Hostname=vkwin-exc01.techspacekh.com] 1699 bytes in 0.111, 14.884 KB/sec Queued mail for delivery) Jun 10 08:37:50 vkcent-web01 postfix/qmgr: CE12860026D: removed
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.