After enabling Spam Assassin on my Plesk Managed Media Temple DV3 Server, I had been relying on email clients to move spam-tagged emails into a “Junk” folder.
This was not working out on my newly purchased Iphone, I was receiving Spam mail in my inbox, over 100+ every so many hours.
It only worked when the e-mail client was open, rules/filters had to be set up on the email client, and the rules/filters do not transfer to the phone mail client.
After a lot of digging around 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.
The following steps apply to my mailbox “russ” on domain “wittmannwebweaving.com” You will need to substitute your own mailbox and domain.
Step One:
Create /var/qmail/mailnames/wittmannwebweaving.com/russ/.procmailrc
MAILDIR=/var/qmail/mailnames/wittmannwebweaving.com/russ/Maildir
DEFAULT=${MAILDIR}/
SPAMDIR=${MAILDIR}/.Junk/
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.*
${SPAMDIR}
Step Two:
Edit /var/qmail/mailnames/wittmannwebweaving.com/russ/.qmail
so that it contains only the following two lines:
| /usr/local/psa/bin/psa-spamc accept
|preline /usr/bin/procmail -m -o .procmailrc
That’s it pretty simple! Let me know your feedback, its working great for me.








July 16, 2007 at 7:22 am
Thanks Russ!
Procmail is a great little app that will makes life much easier for (dv) users, those that can figure it out that is… but this is a very well done and simple article! I’ll see what I can do about getting it into the KB.
Cheers,
Dain
July 16, 2007 at 10:05 am
No Problem,
I’m also working on getting a SVN article up soon as-well
March 4, 2011 at 5:33 pm
This does not seem to work on a Plesk 10 server.
Any ideas?
March 13, 2011 at 8:35 am
I have not tried this on plesk 10, sorry. Currently on all the new DV 4 I’m using google hosted mail.
July 16, 2007 at 10:39 am
This is a great suggestion.
August 7, 2007 at 10:41 am
Great tip – just wondering, is there a way to add this to all accounts automatically?
August 7, 2007 at 10:43 am
I’ll have to see, right now its a manual process
August 7, 2007 at 11:03 am
Also, I just realized I’m getting this error:
:
Usage: spamc [options]
August 7, 2007 at 11:04 am
Crud, that didn’t come through:
Usage: spamc [options]
August 7, 2007 at 11:17 am
What’s the error? What kind of server are you on? Do you have spam assassin?
February 19, 2008 at 7:26 pm
Do you have to make that “Junk” folder ahead of time or do these scripts take care of that?
February 19, 2008 at 8:14 pm
Nope, the scrip makes it when Junk is received, send your self an email with this is the message body to test it out.
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34XFebruary 19, 2008 at 9:16 pm
Ok that test message came in marked as spam but it did not go into a Junk folder. I did want to point out that I am on one of the new DV 3.5 servers and I’m wondering if that changes some of the setup here. Thanks for all your help.
April 26, 2008 at 4:09 am
Hi ,
Hi Friends,
After implementing procmail my mails are stucking in th queue. here is the .procmailrc file
MAILDIR=/home/vpopmail/domains/example.com/tarak.ranjan/Maildir
DEFAULT=${MAILDIR}
SPAMDIR=${MAILDIR}/.Spam/
LOGFILE=${MAILDIR}/procmail.log
LOG=”- Logging ${LOFILE} for ${LOGNAME} ”
:0
* ^X-Spam-Status: Yes.*
${SPAMDIR}
and my .qmail file contain
|preline /usr/bin/procmail -m -o .procmailrc
#/home/vpopmail/domains/liqwidkrystal.com/tarak.ranjan/Maildir/
, im not able to find out where going wrong.
qmail-send log
@4000000048130959266bb75c status: local 1/10 remote 0/30
@400000004813095926f34e4c delivery 159: deferral: procmail:_Couldn’t_create_”/var/mail/vpopmail”/
@400000004813095926f47b14 status: local 0/10 remote 0/30
June 18, 2008 at 5:19 pm
What about when mchk runs? That rebuilds all the .qmail files, and either will drop the changes, or fail if the file is immutable:
“/usr/local/psa/admin/sbin/mchk –with-spam
mchk: Unable to truncate or create file .qmail: Permission denied
System error 13: Permission denied
mchk: Unable to truncate or create file .qmail: Permission denied
System error 13: Permission denied
mchk: Unable to create .qmail file
System error 13: Permission denied
mchk: Unable to create .qmail file
System error 13: Permission denied”
That will leave the qmail system in an inconsistent state, and bork any upgrades.
I find with Plesk it is best to color within the lines.
June 20, 2008 at 1:11 am
@lee I have had no issues with this solution at all running on a DV3 server at mediatemple.
What are you running on?
June 25, 2008 at 10:34 pm
Thanks so much for the tip. One question and one comment:
Comment: I had to ‘chmod popuser:popuser .procmailrc’ so procmail could read it’s own rc file.
Question: My existing .qmail file looked like:
| /usr/local/psa/bin/psa-spamc accept
| true
| /usr/bin/deliverquota ./Maildir
Any idea on what lines 2 & 3 are for? Will they be missed a/o overwritten by plesk?
Thanks again,
Keith
June 25, 2008 at 10:39 pm
It looks like line three is the quota for the account, does the account have a quota?
August 27, 2008 at 2:11 pm
Thank you very much. This is exactly what I’ve been looking for!
I want to make SpamAssassin MARK all messages scored at 1.8 or higher, but I want it to THROW OUT (in this case, redirect) all mail with a score of 5.0 or higher.
My variation uses:
* ^X-Spam-Level: \*\*\*\*\*
instead of
* ^X-Spam-Status: Yes.*
to only filter things that are at least 5.0
The rest comes to the inbox so any ham marked as spam can be identified. Several of my bosses use Treo Smartphones and will love the fact that I’ve just removed 60% of their spam.
Thank you, thank you, thank you!
November 9, 2008 at 3:12 pm
Thanks for publishing this little tutorial. After experiencing up and down service with Google over the past few weeks I decided to move back to Media Temple for email. Everything was going well until I decided to setup the iPhone. Like you, I immediately received a barrage of spam to my iPhone inbox. Hopefully this filter will reduce the number of worthless emails from getting through. Do you have any other tips for teaching SpamAssassin? I’m just beginning to familiarize myself with server side email administration and found things about sa-learn. Are you running any automated scripts to scan spam / ham directories to improve spam filtering?
February 6, 2009 at 1:24 pm
What if I want what to process mail such that if it doe NOT have “Spam-Status: Yes” in the header that it sends the mail to junk?
-Erik
March 7, 2009 at 7:57 am
Russ, you really saved my life.
I’ve been forced to move my company website to a VPS in no time, due to problems with my dmz. It’s two days i’m having that annoying spam tag on mail titles and the think of setting up client rules in more then 40 machines made me sick. Your guide is so damn clear and short, and it works like a charm. Now all the spam go into a junk folder into my account, and using webmail i’m able to forward or delete the junk.
Lovely!
September 21, 2010 at 9:18 pm
I know this has been up a while but I’ve just switched to Media Temple and want to filter my junk the way you describe.
I followed all the steps but my question is how do I access that Junk folder? Do I have to go in through the webmail?
I can’t seem to find the junk folder or figure out how to access it. Do I need to set it up in the webmail?
Thanks.