Thursday, 14 May 2015

Configure Postfix as a Gateway for Exchange

In this tutorial, we will configure Postfix as a Mail Gateway for a backend Exchange Server or any other back-end mail server. This configuration provides several advantages such as blocking unwanted traffic, virus-scanning ,spam prevention, reduce load on back-end. 

We will configure a Mail Gateway on '', so that it relays mail for the domain '' to a mail server on the internal network ''

1) Edit the file '/etc/postfix/'. Make the following changes

    myhostname =
    mydomain =

    #the default domain name to append if @domain is missing
    myorigin = $mydomain

    # the network interface addresses on which to receive incoming mail.
    inet_interfaces = all
    # remember to comment this line
    #inet_interfaces = localhost

    #this machine is not the final destination for any domain
    mydestination = 

   #turn off local recipient checking
   local_recipient_maps =

    #Trusted SMTP clients - can relay mail through this server.  
   mynetworks =,

    # Relay mail for the domains listed below
    relay_domains =

    # Accept mail only for relay users listed in relay_recipients file
    relay_recipient_maps = hash:/etc/postfix/relay_recipients

    # Where to relay mail
    transport_maps = hash:/etc/postfix/transport

2) Create the file  '/etc/postfix/relay_recipients' containing the list of mail recipients for the domain ''    x            x        x

3) Recreate the relay map
[root@meru ~]# postmap /etc/postfix/relay_recipients

4) Edit the file '/etc/postfix/transport' and add the name of the back-end mail server to which to relay mail for the domain ''.  smtp:[]

5) Recreate the transport map.
[root@meru ~]# postmap /etc/postfix/transport

6) To view the parameters changed run the following command.
     postconf -n

7) To check for systax errors, run the following command.
     postfix check

8) Open firewall port 25/TCP.
    firewall-cmd --zone=public --add-service=smtp --permanent
    firewall-cmd --reload

9) Restart postfix service
    systemctl restart postfix

No comments:

Post a Comment