Get the members of a Zimbra distribution group from the command line. The admin console shows members too, but zmprov is quicker on a large server, easy to script, and works over SSH.
Prerequisites
- Shell access to the Zimbra server (any version with
zmprov, Zimbra 8 through 10). - The full address of the distribution list.
1. Switch to the zimbra user
To get the members of a distribution list in Zimbra, login, and su to the zimbra user. The Zimbra tools are on that account’s PATH, not root’s.
su - zimbra

2. Get the distribution list
Issue the following command. gdl is short for getDistributionList; it prints all of the list’s attributes followed by a members section, and piping to tail shows the end of the output where the members are.
zmprov gdl DistributionList@Domain.com | tail

This should output a list of “members” at the end. If it’s a large distribution list, you may want to modify the | tail command like so:
zmprov gdl netflix@zwiegnet.com | tail -n 100

This will show the last 100 lines or so of the output, rather than the default last 10.
Print only the member addresses
Members are stored in the zimbraMailForwardingAddress attribute, so you can ask for just that attribute and skip the tail guesswork:
zmprov gdl netflix@zwiegnet.com zimbraMailForwardingAddress
zmprov gdl netflix@zwiegnet.com zimbraMailForwardingAddress | grep -c zimbraMailForwardingAddress
The second command counts the members.
Related commands
zmprov gadllists every distribution list on the server.zmprov gdlm user@domain.comshows which lists an account belongs to.zmprov adlm list@domain.com user@domain.comandzmprov rdlm list@domain.com user@domain.comadd and remove members.
Troubleshooting
- zmprov: command not found: you are still root. Run
su - zimbrafirst. - ERROR: account.NO_SUCH_DISTRIBUTION_LIST: the address is wrong or it is an alias; check the name with
zmprov gadl | grep -i listname. - Output is slow: plain
zmprovstarts a new Java process each time. For many lookups, runzmprov -l(LDAP mode) or open an interactivezmprovsession and type the commands there.
That’s it!
Related guides: Find out what version of Zimbra you are running | Restart Zimbra Community Services CentOS 6
