I took this one step further and wrote a script that actively finds distribution list members who do not have an account. There may be a few situations it doesn't catch correctly, but I just used it to clean up a dozen entries left over from migrating to Zimbra on one of our customers' systems.
Code:
#!/bin/bash
# This script finds distribution list members who do not have a local account or alias
# Matching entries meet the following criteria:
# 1) Member does not have a local mailbox or alias
# 2) Member is not a local distribution list
# 3) Member's domain is local
# Get a list of local accounts and aliases
localaccounts=`zmprov gaa -v | grep -E '^(# name|zimbraMailAlias)' | cat -s | sed 's/^zimbraMailAlias: //; s/^# name //'`
# Get a list of distribution lists
distlists=`zmprov gadl`
# Combine the account and distribution lists
accounts=`echo $localaccounts; echo $distlists`
# Get a list of local domains
domains=`zmprov gad`
# Find all lists and verify their members
for list in `zmprov gadl`
do
# First get a list of members of this list
members=`zmprov gdl $list | grep "Address" | cut -d " " -f 2`
# Check each member of this list to be sure they have a local account
for member in $members
do
# Does this member have a local account (or alias)?
if [ `echo $accounts | grep $member -c` -ne 1 ]
then
# Found an entry in this list which doesn't have a matching local account
# Verfiy that the domain of this member is local
thisDomain=`echo $member | sed 's/.*@//'`
if [ `echo $domains | grep $thisDomain -c` -eq 1 ]
then
# This domain is local
echo $member in $list does not have a local zimbra account
fi
fi
done
done