How to setup Postfix Transport to Route the email messages

This post will show you how to route messages to other mail server using postfix transport file. This feature allows you to perform mail routing to respective host according to the map defined. Postfix will checking the transport map first instead of reading the DNS for MX record. The steps was tested on CentOS 6.5 and Postfix 2.6.6.

1. In order for Postfix to use the transport file, configure main.cf to use transport map :

vi /etc/postfix/main.cf

Append the following at the bottom :

transport_maps = hash:/etc/postfix/transport

2. Edit transport map file :

vi /etc/postfix/transport

Append the following at the bottom :

ehowstuff.local           smtp:[192.168.0.2]

3. Rebuild the transport database file :

[root@mx-mx06 ~]# postmap /etc/postfix/transport

Note : The command “postmap /etc/postfix/transport” should be execute whenever you change the transport table.

READ  How to Install Zabbix 2.2 Server on CentOS 6.5

4. Reload postfix to apply the new transport :

[root@mx-mx06 ~]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system

5. Verify :

[root@mx-mx06 ~]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mx.ehowstuff.local ESMTP Postfix
ehlo abc.com
250-mx.ehowstuff.local
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:root@ehowstuff.local
250 2.1.0 Ok
rcpt to:root@ehowstuff.local
250 2.1.5 Ok
data
354 End data with .
.
250 2.0.0 Ok: queued as D02D861B50
quit
221 2.0.0 Bye
Connection closed by foreign host.
1 comment
  1. Jeevan Anto
    Jeevan Anto
    July 4, 2017 at 3:33 pm

    ehowstuff.local smtp:[192.168.0.2] should be ehowstuff.local smtp:[192.168.0.2]:25

    Reply
Leave a Reply

Your email address will not be published. Required fields are marked *

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee