Set-Up for postfix + procmail sans local users

The goal in my setup is to remove the local users from the local delivery for email. This enables me to have many more users than I do local users in the linux passwd file. But I also want to use the flexibility of procmail to improve the filtering of spam and other stuff.

Ordinarily procmail is used via the postfix mailbox_command= statement. But this only applies to local users. Instead you need to edit postfix main.cf with

#/etc/postfix/main.cf
mailbox_transport=procmail

This sets up a procmail transport that you need to identify in master.cf:

#/etc/postfix/master.cf
procmail  unix  -       n       n       -       4       pipe
        flags=DRhu user=mail argv=/usr/bin/procmail -a ${recipient}

(NOTE: I stole this from a reference for maildrop…) This puts all the email from postfix into procmail using only the rules in /etc/procmailrc

#/etc/procmailrc
LOGFILE=/var/log/procmail.log
DEFAULT="| /usr/sbin/dbmail-smtp -d $1"
LASTFOLDER="| /usr/sbin/dbmail-smap -d $1"
LOGABSTRACT=yes
VERBOSE=yes
COMSAT=no

# remove duplicated emails - ie: mailing list replies.
:0 Wh: msgid.lock
| formail -D 2048 msgid.cache

:0
| /usr/sbin/dbmail-smtp -d $1

:0e
{ EXITCODE=75 HOST }

At this point, the actual procmail script processes all email delivered to dbmail. With the exception of the formail statement above, this code actually doesn't really do anything. But if you want to insert something like spam filters or other custom goodies that aren't available from postfix content_filters – this is the place to put it.

Enjoy!!


If you call procmail as /usr/bin/procmail -p then it will keep the environment postfix provides; the procmailrc will then have access to the variables DOMAIN, EXTENSION, LOCAL, LOGNAME, RECIPIENT, SENDER et cetera (cf “man 8 local” for the full list).

This of course does not preclude also adding ”-a” options (as done above) to pass additional arguments to the procmailrc.

 
postfix/procmail.txt · Last modified: 2012/02/27 21:33 by bas
 
DBMail is developed by Paul J Stevens together with developers world-wide