Mailboxes By Distribution List

Revision as of 01:25, 16 August 2010 by Richardteachout (talk | contribs) (Initial Creation page.. hope it helps someone else.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

One of our domains has about 100 distribution lists for each of their departments/offices, and requested a way to get a breakdown of all of their users, and which distribution lists they were in.

I saved this file in /opt/zimbra/backup/scripts/ as userbreakdown.sh, owned by zimbra.zimbra chmod 755 userbreakdown.sh

#!/bin/bash
output="/tmp/distlistbreakdownfile"
domain="yourdomainnamehere.com"
SendTo="zimbra_reports@$domain"

rm -f $output
touch $output

for i in `zmprov -l gaa | grep $domain|sort`
do
echo "$i" >> $output
zmprov gam $i|while read line; do echo "     $line" >> $output; done
done
cat $output | mail @SendTo -s"User/Distribution list Breakdown for $domain"


Then I just setup a cronjob (crontab -e as zimbra user) to run this at 4:01 every monday morning, and email it to them.
1 4 * * 1 /opt/zimbra/backup/scripts/userbreakdown.sh

You could easily modify this to run through each domain on your server, and send a report to each domain, if you wanted (just add another for loop)
The output looks something like this (alphabetically for all users)

user1@yourdomainnamehere.com 
   admin@yourdomainnamehere.com
   allemployees@yourdomainnamehere.com
   all_southern@yourdomainnamehere.com (via southern@yourdomainnamehere.com)
   southern@yourdomainnamehere.com (via northern@yourdomainnamehere.com)
   all_employees@yourdomainnamehere.com (via admin@yourdomainnamehere.com)
   northern@yourdomainnamehere.com
user2@yourdomainnamehere.com 
   allemployees@yourdomainnamehere.com
   all_southern@yourdomainnamehere.com (via southern@yourdomainnamehere.com)
   southern@yourdomainnamehere.com (via northern@yourdomainnamehere.com)
   northern@yourdomainnamehere.com
etc

They then can at a quick glance, see if there are any users in NO distribution lists, for example, without having to go through each user one by one, or each distribution list! :)

Jump to: navigation, search