A short link to this page is https://wiki.list.org/x/4030585

Clear message

4.15. How do I filter incoming mail before it hits mailman (e.g., using procmail)

I spam filter incoming mail on my public lists using procmail. It doesn't require changing either procmail or Mailman. What I did was put my procmail filter in /etc/procmailrcs/mailman (your procmail may want it somewhere else) and change the ownership so that it belongs to the group that I configured mailman's "--with-mail-gid=", in my case nobody.nobody.

I replaced the mail list alias, from

    lugor-announce:          "|/usr/home/mailman/mail/wrapper post lugor-announce


    lugor-announce:          "|/usr/bin/procmail -m MAILMAN=lugor-announce /etc/procmailrcs/mailman

The procmail filter I use stores spam in a folder for review in mailman's Mail directory, but they belong to "nobody", not "mailman", which can be a minor problem at times. The last lines of the procmail filter pass the mail (if it wasn't filed as spam) to mailman with the commands:

    |/usr/home/mailman/mail/wrapper post ${MAILMAN}

If you use smrsh you'll have to put a link to procmail in to /etc/smrsh for this to work, e.g.

  cd /etc/smrsh
  ln -s /usr/bin/procmail

Because I used to use an older version of Mailman that mistook the "Sender:" header for the envelope sender (somebody misread RFC 822!), I also used that procmail filter to strip out the Sender header, using the lines:

    :0 f
    | formail -R "Sender:" "X-Former-Sender:"

before the lines above.

Converted from the Mailman FAQ Wizard

This is one of many Frequently Asked Questions.