On a typical Unix Plesk installation, you will find your mailbox settings under this folder
/var/qmail/mailnames/(yourdomain)/(yourmailuser)
Each mail account folder will have a directory listing similar to the following:
drwx------ 5 popuser popuser 4096 Apr 4 13:55 .
drwx------ 5 popuser popuser 4096 Mar 23 2006 ..
-rw------- 1 popuser popuser 329 Mar 23 2006 .qmail
drwx------ 2 popuser popuser 4096 Nov 15 12:00 .spamassassin
drwx------ 2 popuser popuser 4096 Mar 23 2006 @attachments
drwx------ 8 popuser popuser 4096 Feb 2 21:17 Maildir
-rw------- 1 popuser popuser 12288 Feb 2 19:21 auto-whitelist
-rw------- 1 popuser popuser 12288 Apr 4 13:55 bayes_seen
-rw------- 1 popuser popuser 12288 Apr 4 13:55 bayes_toks
-rw-r--r-- 1 root root 61 Mar 23 2006 user_prefs
If you have Spamassasin enabled for the mail account, you will see the .spamassassin file and the bayes files. Otherwise, you can create these files and invoke Spamassassin for each mail account required.
These steps can also be helpful if you have disabled Spamassassin under Plesk but you would like to use it on new mailboxes.
First, you will need to modify the .qmail file. Plesk will create this file with the following contents:
| if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc -f -u sales@mydomain.com -U /tmp/spamd_full.sock > spamcheck$$; /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "" "" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; retval=$?; rm -f spamcheck$$; [ $retval = 0 ] && exit 99; exit $retval; fi
| true
./Maildir/
Using your favorite editor, open .qmail and change it to the following
| preline /usr/bin/procmail -p -m .procmailrc
This instructs qmail to call procmail each time a message is delivered into your mailbox. From here, procmail will handle the invoking of Spamassassin and other mail sorting.
Next, create a file called .procmailrc and paste the following into it.
# Run SpamAssassin
:0fw
| spamassassin
# Move spam to the .Junk folder
:0:
* ^X-Spam-Status: Yes.*
./Maildir/.Junk/
# Let other mail go through
:0:
*
./Maildir/
The procmail file can give you tons of flexibility on dealing with mail as it arrives. Notice the line ./Maildir/.Junk/ which is the target folder to move spam into. Depending on what email client you use, you may not have this folder in your Maildir folder. Check your Maildir folder and see what works best for you, which may be .Spam or .Trash
Finally you will need to have a user_prefs file in your mailuser folder. This file contains simple settings for Spamassassin that are for each mail user.
required_hits 7
rewrite_subject 1
subject_tag *****SPAM*****
rewrite_header Subject ****SPAM(_SCORE_)****
It is important to note that these settings change with different versions of Spamassassin. You will need to determine the version you have and the appropriate settings values.
Now you can easily copy these three files to other mailboxes and enable Spamassassin on any mail account.
Update
If you are interested in using a script to generate the .qmail and .procmailrc file server wide, see the article Plesk Default Settings Script for qmail and procmail
7 replies on “Procmail filtering with Plesk and Spamassassin”
your post has help me find the procmail solution that i was looking for. is their a way to do this server wide on plesk.
I do not know of a way to do this server wide, but my guess is there may be a script executed by plesk during the mailbox creation. Otherwise one could build a script to iterate all the mailbox folders and copy the settings files into them.
Where you say “Next, create a file called .procmail and paste the following into it.”, with “.procmail” in bold, you meant to say “.procmailrc” (with the “rc” at the end). Or the other way round, when invoking procmail, remove the “rc” at the end… 🙂
Rejo, Thanks for the catch, the article is now updated with “.procmailrc”
Well I had to do this server wide so I added another post with a script that can create .qmail and .procmailrc files for all mailboxes.
http://www.europheus.com/?p=66
Your post did help alot, but there is a small problem, I am using Plesk 8.4 on Ubuntu and I had to erase the last Asterisk (*) from this line:
* ^X-Spam-Status: Yes.
I am not familiar with the syntax, however this worked for me and I thought I should send my input.
the article has assisted me on my dilemma