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):
Now make the file executable and run it: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
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)"|^[^"].*$)
Awesome! Just what I was looking for. Thanks!
My pleasure!
How do you get a list of users if you are running in windows xp?
@robert
If you install Cygwin on your Windows XP system (see cygwin.com) you’ll have all that you need (including Python) to run the scripts above. [I just discovered this -- won't tell you how long I've been looking for something I could script locally. Thanks, folks.]
I was looking for. Thanks
Hi, will this export ALL member info that is available in mailman?
And can this be useful in importing all the members back into a fresh mailman install – with all member attributes?
One small nit – way too many cats. All your cats can just be removed.
For example, “ls /usr/local/mailman/lists | cat > lists.txt” is exactly equivalent to “ls /usr/local/mailman/lists > lists.txt”.
@Ken You’re right
How can i do the opposite?
i mean i have a csv file which contains a list of members, i want to put all members in my mailing list using cli.
any idea?
thanx
Have a look at Mailmans bin directory. On Debian it’s at /usr/lib/mailman/bin.
You’ll want to use the add_members script to do what you need. Note that your csv needs to be of the format: