Exporting all addresses (mailboxes, aliases and distribution lists) is a vital tool if you have a backup MX and only want it to accept email for valid recipients. One reason for that is to stop spammers who simply use a dictionary of common names to generate recipient email addresses which would flood a backup MX with undeliverable email. Some anti-spam providers (e.g. Postini) have automatic provisioning processes for making this possible.
A native process of extracting mailboxes looks like this:
/opt/zextras/bin/zmaccts | grep 'active' | egrep -v '^\W+' | awk '{print $1}'
Unfortunately, this doesn’t give distribution lists and aliases, so a more sophisticated approach is necessary, for which there is no specific tool and requires using the ldap tool thus:
/opt/zextras/common/bin/ldapsearch -LLL -x -D"/opt/zextras/bin/zmlocalconfig -s zimbra_ldap_userdn | \ awk '{print $3}'" -w"/opt/zextras/bin/zmlocalconfig -s zimbra_ldap_password | \ awk '{print $3}'" -H /opt/zextras/bin/zmlocalconfig ldap_url | \ awk '{print $3}' $* | \
grep ^mail | \
awk '{print $2}' | \
sort > carbonio_recipients.list