relay
Relay Tips Based on User/Domain Sender on Zimbra 8.5-8.6
1. Add following line to /opt/zimbra/postfix/conf/main.cf
sender_dependent_relayhost_maps = hash:/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 [20.20.20.1]
You can even add individual email IDs to relay their emails to specific relay host.
user@domain.com [10.10.10.2]
3. Create the hash file.
postmap /opt/zimbra/postfix/conf/bysender
4. Restart zmmtactl
zmmtactl restart
Sending mail through an external relay
# Add the following configuration in /opt/zimbra/postfix/conf/main.cf
sender_dependent_relayhost_maps = lmdb:/opt/zimbra/postfix/conf/bysender
# Create file above and adding users/domains would be relay
vi /opt/zimbra/postfix/conf/bysender
Fill as the following example
@domain2.com [relay.example.com]
user1@domain1.com [relay.example.com]
configuration above will do relay every sending email from @domain2.com and user1@domain1.com to relay server at relay.example.com
# Postmap file
postmap /opt/zimbra/postfix/conf/bysender
# Reload Postfix
postfix reload
Relay per Domain
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 [20.20.20.1]
You can even add individual email IDs to relay their emails to specific relay host.
user@domain.com [10.10.10.2]
3. Create the hash file.
postmap /opt/zimbra/postfix/conf/bysender
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
Description:
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]
user@domain2.com [20.20.20.1]
4. Create the hash file.
postmap /opt/zimbra/common/conf/bysender
5.
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
lmdb:/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.
setting zimbraMtaRelayHost in Zimbra Administration UI
Global Settings
Click on Global Settings in the navigation tree and open ""MTA"" tab:
Type relay MTA host name and port number into the text fields next to ""Relat MTA for external delivery"" field. To add more external relays click ""Add"" button.
Server Settings
Select the server in the navigation tree or click on ""Servers"" in the navigation tree and select the server in the table
Type relay MTA host name and port number into the text fields next to ""Relat MTA for external delivery"" field. To add more external relays click ""Add"" button.
Zimbra SMTP relay for multiple domains via MailGun
First, run the following commands and take note of their settings in the event you ever have to undo this. Their expected results are listed below:
zmprov -l gs `zmhostname` | grep -i zimbraMtaSmtpSaslPasswordMaps
[empty]
zmprov -l gs `zmhostname` | grep -i zimbraMtaSmtpSaslAuthEnable
no
zmprov -l gs `zmhostname` | grep -i zimbraMtaSmtpCnameOverridesServername
no
zmprov -l gs `zmhostname` | grep -i zimbraMtaSmtpSaslSecurityOptions
noplaintext,noanonymous
zmprov -l gs `zmhostname` | grep -i zimbraMtaSmtpSaslMechanismFilter
[empty]
Second, the following command to change these settings:
zmprov ms `zmhostname` zimbraMtaSmtpSaslPasswordMaps "lmdb:/opt/zimbra/conf/relay_password"
zmprov ms `zmhostname` zimbraMtaSmtpSaslAuthEnable yes
zmprov ms `zmhostname` zimbraMtaSmtpCnameOverridesServername no
zmprov ms `zmhostname` zimbraMtaSmtpSaslSecurityOptions "noanonymous"
zmprov ms `zmhostname` zimbraMtaSmtpSaslMechanismFilter "plain,login"
zmprov ms `zmhostname` zimbraMtaSmtpTlsSecurityLevel may
Third, as noted in one of the links above, “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
I found the “SECTION mta” entry and pasted it right above the “RESTART mta” entry around line 276 but this may vary depending on your version.
Fourth, execute this to tell the new config parameter where to look for the relay domain instructions:
cat >> /opt/zimbra/conf/postfix_sender_dependent_relayhost_maps.cf
lmdb:/opt/zimbra/common/conf/relay_domain_conf
Fifth, in /opt/zimbra/common/conf/relay_domain_conf add the following:
@domain.com smtp.mailgun.org@domain2.com smtp.mailgun.org@domain3.com smarthost.securence.comSixth, run this as the “zimbra” user:
postmap /opt/zimbra/common/conf/relay_domain_conf
And finally:
postfix reload
Now log in as one of those accounts and send a test email to yourself. Once you receive it check the mail headers. You should see something similar to this:
X-Mailgun-Sending-Ip: XXX.XXX.XXX.XXX
X-Mailgun-Sid: WyIz4fgzfiIsICJrQl0aEB3YXZlbAW90a33uZGlnaXRhbC5jb20iLCAiYTFjMmUyIl0=
Sender: user=domain.com@mg.wavemotionmail.com
Received: from mail.originserver.com (Unknown [XXX.XXX.XXX.XXX]) by
mxa.mailgun.org with ESMTP id 5e822697.7fa61bfc2eb0-smtp-out-n03; Mon, 30
Mar 2020 17:04:23 -0000 (UTC)
setting zimbraMtaRelayHost in Zimbra Administration UI
Global Settings
Click on Global Settings in the navigation tree and open ""MTA"" tab:
Type relay MTA host name and port number into the text fields next to ""Relat MTA for external delivery"" field. To add more external relays click ""Add"" button.
Server Settings
Select the server in the navigation tree or click on ""Servers"" in the navigation tree and select the server in the table
Type relay MTA host name and port number into the text fields next to ""Relat MTA for external delivery"" field. To add more external relays click ""Add"" button.