How to setup Postfix Transport to Route the email messages

Share this Article :

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 :

[[email protected] ~]# postmap /etc/postfix/transport

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

4. Reload postfix to apply the new transport :

[[email protected] ~]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system

5. Verify :

[[email protected] ~]# 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
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.

Leave a Reply