Automatically moving spam to a junk mailbox under a Plesk 9 server

This is just a quick note on how I was able to get this working under plesk 9, which seems frustratingly limited in its mail filtering ability. Essentially there’s an option to automatically delete all mails identified as junk – but nothing to enable you to simply move them into a junk directory (which is useful in cases where some emails may be misidentified as spam)

Well I found a similar thread which probably worked for plesk versions < 9, but didn't quite work for me:

I adapted this slightly, also using procmail as the delivery agent.
My server had a .qmail in /var/qmail/mailnames/domain/username/ with the following contents:

| true
| /usr/bin/deliverquota ./Maildir

It seems that it was using the executable ‘deliverquota’ to do the actual mail delivery (and presumably check that quotas are not exceeded for the user)
I’m not worried at all about mail quotas on my server, so I decided to replace the ‘deliverquota’ with a call to procmail

So these are the steps I took

I changed the .qmail above to

| true
|preline /usr/bin/procmail -m -o .procmailrc

I then added a file .procmailrc in the same directory, as described in the thread above – you have to adapt this to have your domain name and mail user name on the first line where MAILDIR is defined:

* ^X-Spam-Status: Yes.*

Lastly, you have to make sure that the ownership and permissioning for both the .qmail and .procmailrc above are correct, otherwise things just won’t work. For me, that meant changing the ownership and group to popuser and permissions to 600 with:
chown popuser:popuser .qmail .procmailrc
chmod 600 .qmail .procmailrc

That’s it! Now the junk mail (provided spamassasin is set up and working, adding it’s headers) should go to the .Junk directory for the user. I have sacrificed the disk quota functionality for this, but it seems a worthwhile exchange for me.

To test this you can send a ‘GTUBE’ test email (an email with content which tells spamassasin to treat it as spam) from another email account, just add the following as the message body


For me the mail logs on plesk server seem to be at /usr/local/psa/var/log
If the above doesn’t work, have a look in the log, it may give you some clues as to why

Hope that helps

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply