"""Discard all held posts and subscription requests from a specific address. Save as bin/discard_address.py Run via bin/withlist -a -r discard_address -- where is the actual email address whose posts and subscribe requests are to be discarded. Discards will be logged to Mailman's vette log. """ from Mailman import mm_cfg def discard_address(mlist, address): if not mlist.Locked(): mlist.Lock() heldmsgs = mlist.GetHeldMessageIds() pendingsubs = mlist.GetSubscriptionIds() changed = False for id in heldmsgs + pendingsubs: if mlist.GetRecord(id)[1].lower() <> address.lower(): continue mlist.HandleRequest(id, mm_cfg.DISCARD, 'Discarded by script') changed = True if changed: mlist.Save() mlist.Unlock()