GNU mailman reference

Clearing held messages from moderator queue

With the amount of spam these days, the moderation queue can quickly become unmanageable.

If you need to clear all messages from the queue, look at data/heldmsg* (for my installation, that's /usr/local/mailman/data/heldmsg*).

I don't know if it's safe to just delete the files, but bin/discard can be used to discard them properly:

cd /usr/local/mailman
bin/discard data/heldmsg*

However if the list is very big you'll probably get an “argument list too long” error, so bring in find and xargs:

find data/ -name heldmsg* | xargs -r bin/discard

Job done.

I found that, and further details, from a discarded blog posting (Google archived version)

Automatically discard spam from moderation queue

Also that blog post suggested a good way to scan the queue for spam:

However I want to be really sure that the messages I'm discarding are spam. The most straightforward way to do that is to extract the RFC 2822 messages from Mailman's pickles, and pipe them to spamassassin. I could not find a script for message extraction included with Mailman, so I had to write my own (

    #!/usr/bin/env python
    Extract an email message from a Mailman pickle.
    Usage: filename > outputfile
    import sys
    import cPickle
    sys.path.insert(0, '/usr/lib/mailman') # you might need to change this
    def main(argv=sys.argv):
        if len(argv) < 2:
            print __doc__
        msg = cPickle.load(open(argv[1]))
        print msg.as_string()
    if __name__ == '__main__':

The rest is a matter of simple shell scripting:

    for fn in /var/lib/mailman/data/heldmsg*; do
        ./ $fn | spamassassin -L -e > /dev/null || echo $fn
    done | xargs /usr/lib/mailman/bin/discard

I haven't tried that, but it looks like it should work.

linux/mailman.txt · Last modified: 2010/02/26 10:45 (external edit)
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki