Relay Tips Based on User/Domain Sender on Zimbra 8.5-8.6

Posted by

On previous post, we can relay email based on user/domain receiver. But, on this guidance is reverse from previous post. ie the relay based on user/domain sender. Zimbra supported for multi domain. You can have many domain in one Zimbra server. I have condition where either domain cannot sending to some domains. For example, i have 2 domains in Zimbra server, domain1.com and domain2.com.

domain1.com can sending email to domain3.com but domain2.com cannot sending email to domain3.com. Whereas domain1.com and domain2.com are in one Zimbra server. it is rather strange indeed. For be able sending to domain3.com from domain2.com, i am decide to relay every sending email from domain2.com. For do that, i do the following guidance

# 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

Note : every add/delete users/domains in /opt/zimbra/postfix/conf/bysender, don’t forget to postmap and reload postfix

Good luck and hopefully useful 😀

8 comments

  1. doesnt working for me . I have a global smtp configured already on zimbra 8.6

    maillog error
    Jun 13 12:33:52 mail postfix/trivial-rewrite[4050]: warning: lmdb:/opt/zimbra/postfix/conf/bysender lookup error for “test@example.com”
    Jun 13 12:34:39 mail postfix/trivial-rewrite[4050]: warning: lmdb:/opt/zimbra/postfix/conf/bysender is unavailable. open database /opt/zimbra/postfix/conf/bysender.lmdb: No such file or directory
    Jun 13 12:34:39 mail postfix/trivial-rewrite[4050]: warning: lmdb:/opt/zimbra/postfix/conf/bysender lookup error for “”
    Jun 13 12:34:43 mail postfix/trivial-rewrite[4050]: warning: lmdb:/opt/zimbra/postfix/conf/bysender is unavailable. open database /opt/zimbra/postfix/conf/bysender.lmdb: No such file or directory

    Please help 🙂

  2. Hello this is great but I seem to have a problem:

    postconf -n | grep bysender
    sender_dependent_relayhost_maps = lmdb:/opt/zimbra/postfix/conf/bysender

    ls -lsa /opt/zimbra/postfix/conf/bysender.lmdb
    20 -rw-r–r– 1 zimbra zimbra 20480 Dec 15 17:30 /opt/zimbra/postfix/conf/bysender.lmdb

    cat /opt/zimbra/postfix/conf/bysender
    @mydomain.fr [10.42.0.40]

    postfix reload


    Still I see the messages going by the mx record for the domain.

  3. Hello Iman,

    I have similar “problem”. I like to send mail from my zimbra (8.6) to gmail account but thru smtp.gmail.com,

    I will do all command above but I am not clear how can I authenticate to SMTP.GMAIL.COM?

    ..and if I do steps from previous for authentication post I am afraid that all mail will go thru google … not sure how to combine these two 🙂

    Thank you if you have time to answer

  4. /opt/zimbra/common/conf/main.cf
    To the Last Line of the File

    sender_dependent_relayhost_maps = lmdb:/opt/zimbra/common/conf/bysender
    Added

    /opt/zimbra/common/conf/bysender
    Into the File

    mahbubarice.com.tr [10.10.50.62:25]
    I made the same definition more than once

    su zimbra
    postmap /opt/zimbra/common/conf/bysender
    postfix reload
    I applied

    I Provided The Identification Process,
    Mail When I Test It Only Does Not Reach Through Mail Gateway,
    Direct Zimbra Sending on Server,
    What I Want is to Deliver Mail After Passing Through PMG ?
    Where am I doing wrong ?

    1. Hi Halil Ibrahim Ayhan,
      As I know, PMG uses port 26 for a relay. Please change your relay so that like below

      mahbubarice.com.tr [10.10.50.62]:26
      

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.