Relay per Domain
Relay per Domain
Zimbra allows relaying emails to a specific server only, i.e using zimbraMtaRelayHost. However, there are needs to relay emails per domain basis based on the sender. For example, you want emails sent by firstname.lastname@example.org should be relayed through smtp.domain1.com and email@example.com through smtp.domain2.com servers. You can configure it using postfix's "sender_dependent_relayhost_maps".
This is an example that has been tested on ZCS 5.0.16 and ZCS 7.1.4
Note: Below settings will not survive zimbra upgrades. Make sure you take backup of config files before upgrading.
1. Add following line to /opt/zimbra/postfix/conf/main.cf
Pre 8.5: sender_dependent_relayhost_maps = hash:/opt/zimbra/postfix/conf/bysender 8.5: sender_dependent_relayhost_maps = lmdb:/opt/zimbra/postfix/conf/bysender
2. Create file /opt/zimbra/postfix/conf/bysender and enter your domain names and relay server's IP addresses.
@domain1.com [10.10.10.1] @domain2.com [184.108.40.206]
You can even add individual email IDs to relay their emails to specific relay host.
3. Create the hash file.
4. Restart zmmtactl
zmmtactl stop zmmtactl start
5. Test by sending emails.
ZCS 8.7 instructions
1. Open /opt/zimbra/common/conf/main.cf file for editing with your favorite editor (e.g. vi).
2 . Find the sender_dependent_relayhost_maps parameter and set it to be lmdb:/opt/zimbra/common/conf/bysender
sender_dependent_relayhost_maps = lmdb:/opt/zimbra/common/conf/bysender
sender_dependent_relayhost_maps (default: empty) A sender-dependent override for the global relayhost parameter setting.The tables are searched by the envelope sender address and @domain.
3.Create a file /opt/zimbra/common/conf/bysender and enter your domain names and relay server's IP addresses.
@domain1.com [10.10.10.1] firstname.lastname@example.org [220.127.116.11]
4. Create the hash file.
zmmtactl stop; zmmtactl start
ZCS 8.8 instructions
Take backup of '/opt/zimbra/conf/zmconfigd.cf' and open it with your favorite editor. Look for the "SECTION mta" and add the following line.
POSTCONF sender_dependent_relayhost_maps FILE postfix_sender_dependent_relayhost_maps.cf
Note : Do not add anything with "#" it will create problem as this file don't understand that.
cat >> /opt/zimbra/conf/postfix_sender_dependent_relayhost_maps.cf mdb:/opt/zimbra/common/conf/relay_domain_conf
cat >> /opt/zimbra/common/conf/relay_domain_conf @domain.com 10.137.26.10 postmap /opt/zimbra/common/conf/relay_domain_conf
Restart the MTA service or wait it will take this configuration in the next poll of zmconfigd.