How to set transport in zimbra

How to set transport in Zimbra 8.x

Transport feature allow you to route specific domain mail from different server/Host. Here i am going to route yahoo.com, gmail.com mail from another server.

Server details
Zimbra server hostname: mail.example.com
In example.com cpanel/domain create A record with name relay.example.com domain and point ip address of remote server .
relay.example.com -  x.x.x.x   

For zimbra 8.x
# su - zimbra
$ zmprov ms mail.example.com  zimbraMtaTransportMaps "lmdb:/opt/zimbra/postfix/conf/transportfile,proxy:ldap:/opt/zimbra/conf/ldap-transport.cf"

For zimbra 8.7.0 or above
$ zmprov ms mail.example.com  zimbraMtaTransportMaps "lmdb:/opt/zimbra/common/conf/transportfile,proxy:ldap:/opt/zimbra/conf/ldap-transport.cf"

Check above updated value
$ zmprov -l gs `zmhostname` | grep -i zimbraMtaTransportMaps
zimbraMtaTransportMaps: lmdb:/opt/zimbra/common/conf/transportfile,proxy:ldap:/opt/zimbra/conf/ldap-transport.cf

Edit file main.cf and add below parameter

$ vim /opt/zimbra/postfix/conf/main.cf
smtp_sasl_password_maps=texthash:/opt/zimbra/conf/relay_password
smtp_sasl_auth_enable=yes
smtp_cname_overrides_servername = no
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain,login

Note: make sure above parameter is not repeating in main.cf file . If you find repated parameter remote that line from file carefully.

Create your transport file (owner/group-owner should be zimbra):

$ vi /opt/zimbra/postfix/conf/transportfile
gmail.com     :[relay.example.com]
yahoo.com     :[relay.example.com]

$ postmap /opt/zimbra/postfix/conf/transportfile

Create authentication file
$ vim /opt/zimbra/conf/relay_password
relay.example.com  relay@example.com:passwordhere

$postmap /opt/zimbra/conf/relay_password

Note: On remote server create domain example.com with email id and password. Put the same information in relay_password file.

Update postfix conf file
$postfix reload

Test now mail gmail.com and yahoo.com mail should relay from relay.example.com server.