Results 1 to 7 of 7

Thread: Get all valid email addresses

  1. #1
    Join Date
    Mar 2008
    Location
    North Carolina
    Posts
    24
    Rep Power
    7

    Default Get all valid email addresses

    I am looking to export all VALID email address accepted by Zimbra. I can get the basic account ones...but I am looking to get all alias accounts and all distribution accounts as well. What 'zmprov' command would do this for me?

  2. #2
    Join Date
    Jul 2007
    Location
    Baltimore
    Posts
    1,649
    Rep Power
    11

    Default

    to list all mail accounts with aliases

    Code:
    #!/bin/bash
    
    for i in `zmprov gaa`
    do
      echo $i
      zmprov ga $i | grep zimbraMailAlias
    done
    to list all the distribution lists

    Code:
    zmprov gadl

  3. #3
    Join Date
    Aug 2007
    Posts
    11
    Rep Power
    0

    Default Improved script to include aliases of accounts and dist lists

    I extended the script given above to include aliases of distribution lists and focus on a single domain:

    Code:
    #!/bin/bash
    
    domain="@example.com$"
    accounts="/tmp/zimbra-accounts"
    
    cp /dev/null $accounts
    
    # Get all accounts by domain and loop thru detailed
    # info for aliases
    for a in `/opt/zimbra/bin/zmprov gaa | grep $domain`
    do
        echo $a >> $accounts
        /opt/zimbra/bin/zmprov ga $a | grep ^zimbraMailAlias | awk '{print $2}' | grep $domain >> $accounts
    done
    
    # Get all distribution lists by domain and loop thru
    # detailed info for aliases
    for d in `/opt/zimbra/bin/zmprov gadl | grep $domain`
    do
        echo $d >> $accounts
        /opt/zimbra/bin/zmprov gdl $d | grep ^zimbraMailAlias | awk '{print $2}' | grep $domain >> $accounts
    done
    
    # Sort to alphabetize and eliminate duplicates(?)
    sort -u $accounts | grep $domain
    rm $accounts

  4. #4
    Join Date
    Sep 2006
    Location
    477 Congress Street | Portland, ME 04101
    Posts
    1,374
    Rep Power
    11

    Default

    Try this:

    /opt/zimbra/openldap/bin/ldapsearch -LLL -x -D"`/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_userdn | \
    awk '{print $3}'`" -w"`/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_password | \
    awk '{print $3}'`" -H `/opt/zimbra/bin/zmlocalconfig ldap_url | \
    awk '{print $3}'` $* | \
    grep ^mail | \
    awk '{print $2}' | \
    sort > zimbra_recipients.list


    From the wiki page:
    Exporting all addresses - Zimbra :: Wiki

    Hope that helps,
    Mark

  5. #5
    Join Date
    Aug 2007
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by LMStone View Post

    /opt/zimbra/openldap/bin/ldapsearch -LLL -x -D"`/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_userdn | \
    awk '{print $3}'`" -w"`/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_password | \
    awk '{print $3}'`" -H `/opt/zimbra/bin/zmlocalconfig ldap_url | \
    awk '{print $3}'` $* | \
    grep ^mail | \
    awk '{print $2}' | \
    sort > zimbra_recipients.list
    That's much nicer, faster too, thanks!

  6. #6
    Join Date
    Jul 2007
    Location
    Baltimore
    Posts
    1,649
    Rep Power
    11

    Default

    yeah running zmprov over and over is not very efficient. i know i've seen on some thread where someone openned a pipe to zmprov so it only had to start once and then just fed commnands to it that would probably be the best way of doing things if you need to call zmprov or zmmailbox a lot.

  7. #7
    Join Date
    Sep 2006
    Location
    477 Congress Street | Portland, ME 04101
    Posts
    1,374
    Rep Power
    11

    Default

    I can't take credit for the script of course as I didn't write it.

    But, since we have the same need for a comprehensive list of valid email addresses (non-Zimbra, off site tertiary MX), I had bookmarked that particular wiki page a while back.

    Glad I could help some!

    All the best,
    Mark

Similar Threads

  1. Replies: 2
    Last Post: 05-20-2008, 12:56 PM
  2. need advice on configuring zimbra to work with fax server
    By pheonix1t in forum Administrators
    Replies: 0
    Last Post: 07-11-2007, 08:46 PM
  3. upgrade to 4.0.3 antispam does'nt work
    By lucanannipieri in forum Administrators
    Replies: 14
    Last Post: 11-07-2006, 03:56 AM
  4. Replies: 3
    Last Post: 10-26-2006, 02:57 PM

Posting Permissions

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