The 'moderate-list' script

Moderate-list is a specialised perl MUA script to aid internet mailing list moderation, with support for ezmlm and MailMan 2.1.x list servers. (These mailing list managers both produce 'message awaiting moderation' mails with enough info to allow this to operate.)

Given an MH or Maildir-format mail folder full of 'moderation required' messages, it will iterate through each one, picking out the ones it understands. Each message is scanned using SpamAssassin, using full network tests and whatever other SpamAssassin features you choose to use for moderation, such as its own Bayes database.

Messages that score over the spam threshold are automatically blocked; messages that score under are kept aside for moderation.

If the script is run in automatic mode (with the '--auto' switch), or if STDIN is not connected to a tty, the script will exit with exit code 22 so that calling code will know that the messages were unmoderated. If the script is being run interactively (without '--auto' and with a tty on STDIN), an text-mode interactive UI is used, whereby the user is presented a preview of the message like so:

| From: Felicia <[email protected]>
| To: [email protected]
| Subject: Your one stop prescription shop!
| List-Id:
| Preview: 36 hours: for all your needs :)
| http://recognizable./?lamplightxtvuynaivelyzgvscallops
| Perpetual optimism is a force multiplier.
|  [....cut]
| SpamAssassin: score=0.501/5 rules=AWL,BAYES_50

Moderation action [ynab] (y=yes, n=no, a=allow in future, b=block in future)?

The user then presses one of the choice keys to select the moderation action to perform:

Based on the keys pressed, the script will perform the appropriate action by mailing the moderation addresses defined in the moderation message.

A full log of a sample run can be read at ModerateListSampleRun.

Automatic Mode And Workflow

Automatic moderation is performed using the --auto switch and (optionally) the 'moderate-list-auto-filter' shell script. If you have an incoming mail filter which detects list moderation messages, and can filter incoming mail from that through a shell script filter, this may be useful.

Here are the patterns I'm using for filtering. These match MailMan and the ASF ezmlm lists:

    ^From:.*\S+-reject-\d+\.\[email protected]\S*
    ^Subject:.*post from \S+ requires approval

If a message arrives with these patterns, it is passed through 'moderate-list-auto-filter'. The messages should NOT be spam scanned beforehand -- otherwise you run the risk that your spam scanner will think a message from your MLM notifying you of a spam requiring moderator rejection, is in itself spam!

The 'moderate-list-auto-filter' script runs 'moderate-list' with the --auto switch, and will add a new header to the top of the message indicating if the message was handled automatically or not:

  X-Moderate-List-Performed: yes

That "yes" may be "no" if the moderation could not proceed automatically. You can then move aside messages that have the "yes" pattern, after that filter executes, into an 'auto-moderated' folder.

All other moderation messages should be filed into a 'moderation-required' folder to be processed interactively with 'moderate-list' later.

(TODO: I'm not using procmail, but a procmail rule that implements the above would be nice for other users!)


    moderate-list [options] { --dir maildir | --file filename }
    [... script outputs message synopsis...]
    Moderation action [ynab] (y=yes, n=no, a=allow in future, b=block in future)?
    [... script mails the correct address appropriately.]

    moderate-list --auto [options] { --dir maildir | --file filename }
    [... script operates automatically with no user intervention...]


State files are kept in ~/.moderate_sa.



  mkdir ~/.moderate_sa
  echo "
    use_bayes 1
    bayes_path ~/.moderate_sa/bayes
    trusted_networks        213.228.0/24
    internal_networks       10.19.72/24
    # (...possibly other SpamAssassin configuration if desired)
  " > ~/.moderate_sa/user_prefs

  echo "
    defaultdir /home/you/path/to/moderate/folder
    blockscore 5
  " > ~/.moderate_sa/

Setup For Various MUAs and MDAs

TODO: not yet described. If you do implement the workflow in various clients, feel free to edit this section.


(please edit the page to add comments, or use this QT forum if you don't want to have to register.)

ModerateList (last edited 2005-07-12 20:23:04 by c-24-127-183-241)