ps - Here are a couple of quick throwaway 'withlist' scripts I threw together to add a regexp matching the spammers' email addresses, and to purge pending subscription requests matching a similar regexp. Posting here in case someone finds them useful for this, or some other, purpose.
% cat purge_requests.py # quick "withlist" script. # call via withlist -r purge_requests LISTNAME # or via loop: # for LIST in `./list_lists -b` ; do ./withlist -r purge_requests $LIST ; done import re from Mailman import mm_cfg from Mailman.mm_cfg import DISCARD email_re = re.compile('^(foo|bar.baz|blah)\+[0-9]+@example\.com') def purge_requests(m): print "** Checking %s" % m.internal_name() m.Lock() for item in m.GetSubscriptionIds(): email_addr = m.GetRecord(item)[1] if email_re.match(email_addr): print ">> Discarding %s from %s" % (email_addr, m.internal_name()) m.HandleRequest(item, DISCARD) m.Save() m.Unlock() % cat set_banlist.py # quick "withlist" script. # call via withlist -r set_banlist LISTNAME # or via loop: # for LIST in `./list_lists -b` ; do ./withlist -r set_banlist $LIST ; done # Obviously, the problem becomes a bit more complex if we want to adjust # the existing rule, vs. adding a new one; then we'd have to track the # item # within the list, and modify that item (this also shouldn't be # too hard). from Mailman import mm_cfg # This will append the item below to the ban_list for $LISTNAME # Note additional pattern below; that's just a check to see if the # pattern already exists. ban_item = '^(foo|bar.baz|blah)\\+[0-9]+@example\.com' def set_banlist(m): # Rather than use regex, use this to see if substring is in list if not rule_exists(m.ban_list): print "**** Updating %s" % m.internal_name() m.Lock() m.ban_list.append(ban_item) m.Save() # Could probably do this a little more tersely with 'lambda' def rule_exists(list): for item in list: if '\(foo' in item: return 1 ------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org