Results 1 to 2 of 2

Thread: mail gateway relay_recipient_maps point to Zimbra

  1. #1
    Join Date
    Sep 2006
    Location
    Davis, CA
    Posts
    64
    Rep Power
    9

    Lightbulb mail gateway relay_recipient_maps point to Zimbra

    Working up to a Zimbra migration...

    I would like to keep my mail gateway as the primary relay smarthost for zimbra and other domains in use. The gateway runs postifx.

    I figure in addition to static maps for other domains, I can point the gateway's relay_recipient_maps at LDAP on the Zimbra server for a dynamic map. Or I could regularly export all valid recipients on the zimbra machine and place it in a map on the gateway.

    I think the export is probably the way to go. It would allow the Zimbra server to go down without bouncing any mails.

    It looks like the config for such a map is fortunately in /opt/zimbra/conf/ldap-vam.cf

    Code:
    server_host = ldap://a.host.name:389
    server_port = 389
    search_base =
    query_filter = (&(|(zimbraMailDeliveryAddress=%s)(zimbraMailAlias=%s)(zimbraMailCatchAllAddress=%s))(zimbraMailStatus=enabled))
    result_attribute = zimbraMailDeliveryAddress,zimbraMailForwardingAddress,zimbraPrefMailForwardingAddress,zimbraMailCatchAllForwardingAddress
    version = 3
    bind = no
    timeout = 30

    Which for my gateway would look something like
    Code:
    relay_recipient_maps = 
      ldap:$config_directory/relay_recipients.zimbra.cf
      hash:$config_directory/relay_recipients.sub.domain
      hash:$config_directory/relay_recipients.other.sub.domain
    But to do a full recipient extract, is the following the best way to do that?

    ldapsearch -H 'ldap://a.host.name/' -x '(&(|(zimbraMailDeliveryAddress=*)(zimbraMailAlias =*)(zimbraMailCatchAllAddress=*))(zimbraMailStatus =enabled))'

  2. #2
    Join Date
    Sep 2006
    Location
    Davis, CA
    Posts
    64
    Rep Power
    9

    Post generate static recipient_map

    Maybe no one is doing this. It seems a little more comforting to have a static recipient list than LDAP since I wouldn't want the gw to bounce messages if Zimbra was down on accident or purpose.

    Here's some code to generate such a list.
    Code:
    #!/bin/bash
    ################################################################################
    # $Id: ldap2recipients,v 1.3 2007/03/21 18:27:14 bewley Exp $
    #-------------------------------------------------------------------------------
    # Use this script to generate a list of valid recipients on a Zimbra server.
    # The output is suitable for use by postfix recipient_maps. You might want
    # this if you have an SMTP gateway catching email from the internet before it
    # gets to Zimbra. Postfix could just use LDAP, but what if Zimbra is down?
    ################################################################################
    
    LDAP_HOST=zimbra.dom.ain
    # domain to search in. this is not needed if running as zimbra on localhost
    SEARCH_BASE='dc=dom,dc=ain'
    # default domain for email addresses
    DOMAIN='dom.ain'
    # domains that map to the same as above
    DOMAIN_ALIASES='mail.dom.ain legacy.dom.ain'
    
    OUT=`mktemp -t recipients.XXXXXXXX`
    ldapsearch -x -H "ldap://${LDAP_HOST}/" -b "${SEARCH_BASE}" \
        '(& (|
               (zimbraMailDeliveryAddress=*)
               (zimbraMailAlias=*)
               (zimbraMailCatchAllAddress=*)
            )
            (zimbraMailStatus=enabled)
         )' \
        | grep -E '^zimbraMailDeliveryAddress|^zimbraMailAlias' \
        | sed 's/.*: \(.*\)$/\1/' \
        > $OUT
    
    # one entry per domain and domain alias
    cat $OUT | while read email; do
        user=`echo $email|sed s/@${DOMAIN}$//`
        for dom in $DOMAIN $DOMAIN_ALIASES; do
            echo "${user}@${dom}    ok";
        done
    done
    
    rm $OUT
    Last edited by dlbewley; 03-30-2007 at 03:35 AM. Reason: new version of script for multi domains

Similar Threads

  1. Replies: 7
    Last Post: 02-03-2011, 07:01 AM
  2. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  3. Zimbra shutdowns every n hours.
    By Andrewb in forum Administrators
    Replies: 13
    Last Post: 08-14-2007, 09:55 AM
  4. fresh install down may be due to tomcat
    By gon in forum Installation
    Replies: 10
    Last Post: 07-25-2007, 09:09 AM
  5. Seeming variety of problems on suse-9.1
    By Crexis in forum Installation
    Replies: 52
    Last Post: 03-04-2006, 12:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •