Procmail is available at:http://www.procmail.org/. Procmail is often installed as the default LDA. A simple system wide Procmail Maildir configuration looks like this:
# file: /etc/procmailrc # system-wide settings for procmail SHELL="/bin/bash" SENDMAIL="/usr/sbin/sendmail -oi -t" LOGFILE="/var/log/procmail.log" DEFAULT="$HOME/Maildir/" MAILDIR="$HOME/Maildir/" :0 * ^X-Spam-Status: Yes .spam/
Procmail delivers mails into Maildir folders, if a slash is appended to the folder name (e.g. ".spam/"). But Procmail itself could not update the Dovecot index files. This decreases the performance a bit, because the Dovecot IMAP or POP3 server has to add new mails for the index files.
To increase the performance, it's possible to combine Procmail with Dovecot's deliver tool:
# file: /etc/procmailrc # system-wide settings for procmail SHELL="/bin/bash" SENDMAIL="/usr/sbin/sendmail -oi -t" LOGFILE="/var/log/procmail.log" DELIVER="/usr/lib/dovecot/deliver" # Use the following if you get "destination user parameter (-d user) not given": DROPPRIVS="YES" # fallback: DEFAULT="$HOME/Maildir/" MAILDIR="$HOME/Maildir/" :0 w * ^X-Spam-Status: Yes | $DELIVER -m spam :0 w | $DELIVER
CAVEAT:
On some Debian releases, the permission of /etc/dovecot/dovecot.conf is incorrectly set to 600, which will cause the method above to fail; instead of going to your spam folder, /usr/lib/dovecot/deliver just gives up and dumps it in your INBOX. To fix this, as root you must
chmod 644 /etc/dovecot/dovecot.conf
On a Debian system at 2010-04-04 I found that the delivery wasn't working with an error of "Fatal: destination user parameter (-d user) not given" If I add the following line to the /etc/procmailrc file it fixes the problem: DROPPRIVS=yes It seems the deliver program from Dovecot 1.2 expects a -d parameter if it is run as root, rather than the user that the delivery is being done for.
Lenny Update
On Debian Lenny I had a couple of problems. For historic reasons, I have inboxes in /var/mail/$USER. The most elegant approach was to add the auth master socket in the dovecot configuration, then chmod 1777 /var/mail (root/mail) and use this procmail file:
# file: /etc/procmailrc # system-wide settings for procmail SHELL="/bin/bash" SENDMAIL="/usr/sbin/sendmail -oi -t" LOGFILE="/var/log/procmail.log" DELIVER="/usr/lib/dovecot/deliver" :0 w | $DELIVER -d $LOGNAME
