[Mailman-Users] Manipulating membership management flags (e.g., nomail) from the command-line?

Mark Sapiro msapiro at value.net
Tue Nov 6 18:53:22 CET 2007


Chris Waltham wrote:
>
>A couple of days ago I was troubleshooting an issue for a user and  
>noticed that the "nomail" option was set for them in a particular  
>list. Obviously, because of this, they weren't getting any mail; I  
>presume the flag was set because of bounces.


Maybe. In 2.0, you can't tell for sure.


>My question is this: is  
>there any way that, from the command-line, I can generate a list of  
>users who have a particular flag set -- like the "nomail" flag -- from  
>the command-line? My overall goal is to be able to run a script  
>against every mailing list we have to print me the users with the  
>"nomail" flag set.



Yet another reason to upgrade. The 2.1.x bin/list_members does this.
For 2.0.x, you could modify list_members to add an option similar to
2.1's --nomail, or you could create a simple script along the lines of:

---------------------------------------------------------------------
#! /usr/bin/env python
# This is for Mailman 2.0.x only

import paths

from Mailman import MailList
from Mailman import mm_cfg
from Mailman import Utils

for list in Utils.list_names():
    mlist = MailList.MailList(list, lock=0)
    users = []
    for user in mlist.GetMembers() + mlist.GetDigestMembers():
        if mlist.GetUserOption(user, mm_cfg.DisableDelivery):
            users.append(user)
    if users:
        users.sort()
        print 'Nomail users for list: %s' % mlist.real_name
        for user in users:
            print '    %s' % user
---------------------------------------------------------------------

Save this in Mailman's bin/ directory and run it. I can't test it
completely because it uses Mailman 2.0.x methods which don't exist in
2.1.x, but I think it will work, and if it doesn't, it won't do any
damage.

-- 
Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list