procmail whoes

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
This has been bothering me for days I just can't figure it out.

I have fetchmail which gets mail for all accounts and puts it in the right /home/[user] folder. It also goes through spamassassin to tag it for spam, emails that are spam are put [SPAM] in the title.

I also setted up squirrelmail on the server so I can use webmail and manage my mail that way on the local server, sort of like gmail, but even more control over mail, spamwise and what not.

My problem is, I want all the mail labeled as spam to go in the respectful user's folder.

So I tried using 100's of different procmail recepies (since everyone seems to give different ways of doing it) but none will work.

The problem is that once mail goes through spamassassin, the rest of the procmail filters are compleltly ingored.

See this for example:

Code:
:0 fw
| /usr/bin/spamassassin


:0:
/home/email_redsquirrel/spam

Even this, won't work. This should send all mail to the spam folder of that account (obviously not what I want, but it's a simple test) and even this won't work. If I comment out the spamassassin lines, then it works.

What's up with this? Is there a way to fix this? Thanks. This has been making me go insane for days so I hope someone can help. No other forums I posted at so far can figure it out.
 

Need4Speed

Diamond Member
Dec 27, 1999
5,383
0
0
# call up spamc to process all mail
:0fw
* < 256000
| spamc


# move spam to trash if tagged score is higher than 6
:0
* ^X-Spam-Status: YES
#* ^X-Spam-Level: \*\*\*\*\*\*
$HOME/Maildir/.Trash/cur

 

Need4Speed

Diamond Member
Dec 27, 1999
5,383
0
0
well thats the procmail im using, of course i use spamassassin in daemon mode, hence spamc and not /usr/bin/spamassassin...you need to adjust that for your needs.

the procmail filters are run top to bottom and work perfecly in my setup. I'd recommend you read the docs to procmail and/or SA.
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
Yes because I sent myself an email with the word viagra and mortgage and it makes it as spam, but for some reason it stops going through the procmail list after spamassassin is run. If I comment out spamassassin then any filters I put will work. I'm totally confused.
 

Need4Speed

Diamond Member
Dec 27, 1999
5,383
0
0
LOGFILE=$HOME/procmail.log

add that to the top of your .procmailrc file and then check the log after the email arrives. be sure to delete all your SA databases after u are done testing as it will think that your email addy is a spammer addy.

why are you running it as a perl script rather than the daemon?
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
How can you tell that I'm running as a pearl script? I did not touch it from how it was installed previously. What is the difference? I though spamassassin was simply a command line program that mail is passed to, nothing more.

I sent a spam email to myself but this is all the procmail log says: Folder: /var/spool/mail/email_redsquirrel 1

The spam folder though is in /home/email_redsquirrel/spam and if I cancel out the spamassassin stuff it will put it in that folder, if I set a random rule to do so.
 

cquark

Golden Member
Apr 4, 2004
1,741
0
0
Add a line that says

VERBOSE=on

before the log file directive to see what patterns procmail tried to match against each message and which recipes it executed as a result.
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca

procmail: Executing "/usr/bin/spamassassin"
procmail: [22043] Thu Dec 2 15:58:34 2004
procmail: Assigning "PATH=/home/email_redsquirrel/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin"
Folder: /var/spool/mail/email_redsquirrel 1


We might be getting somewhere... nowhere in there does it say that it's executing the next line (in the user file, but I tried putting it in the main as well)


If I comment out spamassassin I get:


procmail: Assigning "PATH=/home/email_redsquirrel/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin"
From redsquirrel@iceteks.com Thu Dec 2 16:06:38 2004
Subject: [SPAM] test
Folder: /home/email_redsquirrel/spam 747


And my .procmail file in the email_redsquirrel folder has in it:


:0 H
* ^subject:.*\[SPAM\]
/home/email_redsquirrel/spam


But it only works if spamassassin is not run which defeats the purpose of the filter.
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
I guess this is not possible then, what are other alternatives to filter mail the way I need? Remember I need spamassassin to run before the actual filter, since I want mail that is labeled as spam to go in a different folder so that when I login to squirrelmail it's in the right folder. procmail does not seem to have this ability as far as I know since whatever I tried does not work. The way it seems to work is that if you feed the email to a program, it does not come back to do the rest of the filters. I need something that will come back and continue filtering. Is dropmail any good, and would it work with the default red hat imap? I've read on it, but they make it seem like it only works with courrier-imap but I don't want to have to switch imap servers.
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
I forgot to mention I'm running spamassassin 2.31, is this version too old to work with procmail? Maybe that's my problem... do I need to upgrade?
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
Bump, common this can't be this complicated. If yes what's an alternative to procmail then, which does not require any drastic changes to my setup?
 

Red Squirrel

No Lifer
May 24, 2003
71,312
14,084
126
www.anyf.ca
Ok, well I finally figured it out after almost a whole week. I'll post my solution since it's not really obvious.

spamassassin 2.3 is NOT compatible with procmail. The reason apears to be because 2.3 does not output the modified email when it is passed through. So spamassassin <email.txt WILL NOT output the new email. Procmail requires this in order to continue, instead what was happening was that spamassassin took over and delivered the mail after it was done scanning, instead of continuing in procmail. So this is why all the rules I set after were ingored.

So I upgraded to spamassassin 3.0, had a bit of trouble because some default rules made it so it accepts all spam, but I managed to get rid of those default rules and then I had to put rewrite_header Subject (_SCORE_) [SPAM] instead of the old 2 rewrite lines then everything went uphill from there, so I created the .procmail files for all the other users, and now it's smooth. the server seems slow but it's probably because I had cron shutdown during this 2-3 hour upgrade to ensure nothing gets lost. (cron controls fetchmail which gets my mail every 15 minutes) So now cron is just catching up with everything.

So long story short, if procmail rules set after spamassassin don't work, upgrade spamassassin.