msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

23 Mar 18 Changing the mailman subscribers ‘moderation’ bit on the command line

Intro:
In my mailman installation with over 3K subscribers I could not find why the web interface didn’t allow me to change the ‘moderation’ bit of subscribers, or any other property. So I found this tool which allows me to the ‘moderation’ bit for any subscriber using the command line. Sinc ethe Python module for doing this is not provided with mailman you need to add it and run the command as follows:

Add the following content to the new file called: /usr/lib/mailman/bin/mod.py
#! /usr/bin/python
# mod.py
#
from Mailman import mm_cfg
import sys
#
def mod(list):
for member in list.getMembers():
if list.getMemberOption(member, mm_cfg.Moderate):
print member, "is moderated"
#
def set(list, member, value):
value = not not (int(value))
if list.isMember(member):
list.Lock()
list.setMemberOption(member, mm_cfg.Moderate, value)
print "%s's moderated flag set to %d" % (member, value)
list.Save()
list.Unlock()
else:
print member, "not a member"

Command for changing the moderation’ bit:
eg. for myname@mydomain.com in ‘people’ mailing list
Turning ON the ‘moderation’ bit:
/usr/lib/mailman/bin/withlist -r mod.set people myname@mydomain.com 1
Turning OFF the ‘moderation’ bit:
/usr/lib/mailman/bin/withlist -r mod.set people myname@mydomain.com 0
Turning ON the ‘moderation’ bit for ALL subscribers in the mailing list:
for member in $(/usr/lib/mailman/bin/list_members people) ; do
/usr/lib/mailman/bin/withlist -r mod.set people $member 1
done

Leave a Reply

%d bloggers like this: