Category: Mailman

How to get a .csv of subscribers on all your Mailman lists

Posted by on May 16, 2009

The boss asked me to create a list of everyone subscribed to every discussion list we have. Ended up being like 3000 lines…luckly there is a python script that polls the mailman admin web interface. The below script makes it quite a bit easier to perform on all the lists.

First thing, you need a file with all of your list names – this works:

ls /usr/local/mailman/lists | cat > lists.txt ## This is where mailman is located on FreeBSD

Next, download mailman-subscribers.py to your home directory.

Finally, you need to create a shell script (i.e. getallsubscribers.sh) and paste the following (substitute the [[bracketed text]] with the info for your system):

while read line
do
 echo $line | cat >> listsAndMembers.csv
  ~/mailman-subscribers.py -c [[your.mailman.host]] $line [[listAdminPassword]] | cat >> listsAndMembers.csv
  echo | cat >> listsAndMembers.csv
  echo | cat >> listsAndMembers.csv
done < lists.txt
Now make the file executable and run it:
chmod +x getallsubscribers.sh
./getallsubscribers.sh

That's it. You should have a single file with all of your lists and their subscribers.

edit: It came up later that it would be nice to get a list of who from each domain was subscribed. This regex will turn up the listname and name/email for each subscriber in the .csv

(?:.*(?:gmail\.com)"|^[^"].*$)