LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   procmail filters? (https://www.linuxquestions.org/questions/linux-software-2/procmail-filters-261088/)

Red Squirrel 11-30-2004 06:30 PM

procmail filters?
 
I realize these are very complicated, I just can't figure out how to do one simple thing.

I have spamassassin on my server, and also an imap server which is setup with squirrelmail. Most users have a spam folder, so I want all mail that is labeled as [spam] in the title to go in the spam folder of each user.

So if mail sent to user1 is marked with [spam] in the title, then it will go in that user's spam folder.

Can someone show me how to set this up? I searched google like crazy but all sites show a different way and all of them don't work.

Thanks in advance.

foo_bar_foo 11-30-2004 08:51 PM

i guess you use procmailrc either a universal one with a variable that can account for each user or just use
~/.procmailrc in each user home dir
this may or may not help -- i give you the spammassassin part of my ~/.procmailrc
(i don't use imap !) so i don't know about that -- mine is going into a spam file in my ~/mail folder where pine can see it. possibly you can adjust
Code:

:0fw:spamassassin.lock
| spamassassin :0e

  EXITCODE=$?
:0:
* ^X-Spam-Flag: Yes
$HOME/mail/spam


Red Squirrel 11-30-2004 09:13 PM

Yeah I tried it, no luck.

I put in /home/email_redsquirlrel/.procmailrc:

* ^X-Spam-Flag: Yes
/home/email_redsquirrel/spam

The spamassassin stuff is in the global file which is in /etc/procmailrc

Red Squirrel 11-30-2004 09:20 PM

btw what is the ~ mean? Do I need to actually create a folder called that and put the .procmail file in it? maybe that's why it's not working.

twantrd 12-01-2004 02:39 AM

'~' is the user's home directory path.

-twantrd

Red Squirrel 12-01-2004 06:14 PM

Oh I see... I still can't get this filter thing to work though. It's really driving me nuts that it's this complicated.

Red Squirrel 12-01-2004 08:21 PM

Well I might of broke down the problem slightly.

I took off the spamassassin part and now it seems to work - well obviously not the filtering for spam, but filtering in general, since I just used webmin to set a filter to append all mail to a file, and without the spamassassin part being present it does append properly. BUT I want to be able to run spamassassin THEN append to a file only IF spamassassin set the mail as spam. So this is where it's complicated since I assume it's not possible without some intensive config file programming of some sort.

Also when it appends to a file it still sends it to the inbox, so it basically just duplicates it. But before solving that problem I want to make this work even with spamassassin. And I want spamassassin to run first, otherwise it defeats the purpose of the filter.

Red Squirrel 12-02-2004 12:40 PM

'bump' for great justice

Red Squirrel 12-02-2004 06:58 PM

Ok I figured out how to make it produce a log.

So I have a filter to move anything with [SPAM] in the subject to the mail filter, that filter is in the user's .procmailrc, since once I can figure this out I will set the appropriate one in each user.

Then in the global .procmailrc I have run spamassassin.

This is how the log looks like when spamassassin is run:

Code:

procmail: Executing "/usr/bin/spamassassin"
procmail: [23633] Thu Dec  2 19:40:23 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

As you can see it completly ingores the filter to put everything with [SPAM] in the right folder.

In fact I think it's caused by the fact that the date is on it's on line, it's probably that which is screwing things up, I don't even know what the date is doing after that.


If I comment out spamassassin and send an email with [SPAM] in the title:

Code:

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 19:51:43 2004
 Subject: [SPAM] test
  Folder: /home/email_redsquirrel/spam

The rule works.

So what's up with this? Why is it that if a program is executed, that it ingores the rest of the rules? I tried spamc since I've seen some configs use that, but when I use that it simply does not work period, it does not filter for spam. So I need to use spamassassin.

So please if someone can help me it would be apreciated. This is really bugging me big time, that something this simple, is this complicated and hard to do.

Red Squirrel 12-02-2004 10:50 PM

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 12-03-2004 11:42 PM

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.


All times are GMT -5. The time now is 02:28 PM.