# Copyright (C) 2010 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. """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()