The diary and photos of Chris Beach. I'm into windsurfing, coding, badminton, drawing and composing music using computers and synths.

Let's start with a quote:
"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours" Stephen Roberts


email: password:

server-side mail filtering using qmail/procmail/safecat under plesk

After enabling Spam Assassin on my Plesk-managed domain I had been relying on email clients to move spam-tagged emails into a "Spam" folder. This was impractical as it only worked when a client was open, and rules had to be set up on each client.

After a lot of digging on Google I worked out a server-side solution. The key app here is procmail, which runs rules on incoming mails and can file them into folders. Procmail should already be present on your Plesk installation. Another app called safecat is required to place filtered mail into a maildir within the file system. The following steps apply to my mailbox "chris" on domain "chrisbeach.co.uk" You will obviously need to substitute your own mailbox and domain.

1. Create a folder called "Spam" in your mailbox.

2. Install safecat (see http://jeenyus.net/~budney/linux/software/safecat.html)


cd /tmp/
wget http://jeenyus.net/~budney/linux/software/safecat/safecat-1.13.tar.gz
tar xvzf safecat-1.13.tar.gz
cd safecat-1.13
make
make setup check

3. Create /var/qmail/mailnames/chrisbeach.co.uk/chris/.procmailrc


MAILDIR=/var/qmail/mailnames/chrisbeach.co.uk/chris/Maildir
SPAMDIR=${MAILDIR}/.Spam
DEFAULT=${MAILDIR}/
LOGFILE=${MAILDIR}/procmail.log
LOG="--- Logging ${LOGFILE} for ${LOGNAME} "

# All mail tagged as spam (eg. with a score higher than the set threshold)
# is moved to the designated spam folder
:0
* ^X-Spam-Status: Yes.*
| /usr/local/bin/safecat "${MAILDIR}/tmp" "${SPAMDIR}/new"

4. Edit /var/qmail/mailnames/chrisbeach.co.uk/chris/.qmail so that it contains only the following two lines:


| /usr/local/psa/bin/psa-spamc accept
|preline /usr/bin/procmail -m -o .procmailrc

Let me know how you get on, and also if you know of any enhancements I could make to these instructions

written by Chris Beach
01/02/07 2:46pm
(10 years, 9 months ago)
comment 9 comments

photoadd photo

 40 links more journal entries from tech journal