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.







18 responses so far ↓
1 Dain // Jul 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
2 Russ Wittmann // Jul 16, 2007 at 10:05 am
No Problem,
I’m also working on getting a SVN article up soon as-well
3 Ed Shull // Jul 16, 2007 at 10:39 am
This is a great suggestion.
4 Tips For Social Media Marketing - Wittmann Web Weaving // Jul 30, 2007 at 9:53 pm
[…] Sometimes a quick email or note in private telling them you appreciate them can go a long way. Some folks have done that to me, and I do that as well. Only do if sincere. Perhaps this is not truly SMM, but it will help to keep […]
5 David Kaneda // Aug 7, 2007 at 10:41 am
Great tip - just wondering, is there a way to add this to all accounts automatically?
6 Russ Wittmann // Aug 7, 2007 at 10:43 am
I’ll have to see, right now its a manual process
7 David Kaneda // Aug 7, 2007 at 11:03 am
Also, I just realized I’m getting this error:
:
Usage: spamc [options]
8 David Kaneda // Aug 7, 2007 at 11:04 am
Crud, that didn’t come through:
Usage: spamc [options]
9 Russ Wittmann // Aug 7, 2007 at 11:17 am
What’s the error? What kind of server are you on? Do you have spam assassin?
10 Racker Hacker » Mail, Plesk » Sort e-mail in Plesk with procmail // Nov 27, 2007 at 10:28 am
[…] Credit for this trick goes to Russ Wittmann. […]
11 Jonathan // Feb 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?
12 Russ Wittmann // Feb 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.34X13 Jonathan // Feb 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.
14 Tarak // Apr 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
15 lee // Jun 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.
16 Russ Wittmann // Jun 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?
17 Keith // Jun 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
18 Russ Wittmann // Jun 25, 2008 at 10:39 pm
It looks like line three is the quota for the account, does the account have a quota?
Leave a Comment