LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Anyone Filter Email w/ Procmail (https://www.linuxquestions.org/questions/linux-server-73/anyone-filter-email-w-procmail-627876/)

carlosinfl 03-13-2008 04:46 PM

Anyone Filter Email w/ Procmail
 
I am using Postfix to send and receive email on my email server and also have Spamassassin scoring incoming email. I was told that procmail can filter email from Spamassassin into a folder by placing a procmail.rc hidden file in the users home directory to then move mail labeled SPAM in the header into a specific folder. I would love to do this but don't know where to begin on setting something like this up. I am sick of having labeled SPAM in my inbox.

Deleriux 03-13-2008 05:11 PM

Bung this in a file at ~/.procmailrc
Code:

:0H
*^X-Spam-Status: Yes
$HOME/.spam
:0
$MAIL

Note: It might be necessary to override your local delivery mechanism by also adding a .forward file that contains:
Code:

| /usr/bin/procmail -t
Or, you can change your delivery mechanism to include procmail - see your MTA docs about that.

billymayday 03-13-2008 05:18 PM

Postfix will use procmail (they seem to hate it there for some reason), but I use maildrop for the same purpose.

There are a number of ways to do this, one is given above, or a few ways via the transport mechanism. Although for maildrop, I'm sure these would apply for procmail too.

http://www.postfix.org/MAILDROP_README.html

unSpawn 03-13-2008 05:22 PM

Quote:

Originally Posted by Deleriux (Post 3087839)
$HOME/.spam

AFAIK this isn't a standard location like ~/mail/. Consequence of using this location could result in the filesystem filling w/o users noticing.

billymayday 03-13-2008 05:23 PM

May work for maildir?

carlosinfl 03-13-2008 05:58 PM

OK - There is a lot of info here. Let me cap everything up. And by the way I Am using Maildir style, not sure if this makes any difference or not...

1 - I am going to touch ~/.procmailrc as Deleriux suggested.

2 - vim ~/.procmailrc & add what he suggested.

3 - Reload postfix and see if emails that are normally labeled [***** SPAM 6.7 *****] Increase Your Member Size in the subject get filtered w/o having to create a .forward file or adjusting any MTA (Postfix) settings.

Do I need to create ~/.spam or will the .procmailrc file auto generate this for me?

In my /etc/postfix/main.cf, I have the following entry commented out for procmail. Should I enable this setting? Not sure I understand what it does but it seems that it obviously relates to procmail and Postfix.

Code:

carlos@swordfish:~$ cat /etc/postfix/main.cf | grep "procmail"
#mailbox_command = procmail -a "$EXTENSION"


Deleriux 03-13-2008 06:16 PM

Personaly I dont like procmail as it such a cryptic syntax that isnt suitable for users to exploit. Although I didnt suggest it initially i would recommend as the above poster pointed out to use maildir instead of mbox since it is easier to read and simpler to administrate.

carlosinfl 03-13-2008 10:33 PM

Quote:

Originally Posted by Deleriux (Post 3087906)
Personaly I dont like procmail as it such a cryptic syntax that isnt suitable for users to exploit. Although I didnt suggest it initially i would recommend as the above poster pointed out to use maildir instead of mbox since it is easier to read and simpler to administrate.

I am not sure I understand what you mean. I am using Maildir style messaging in Postfix rather than mbox as shown in my config:

Code:

carlos@swordfish:~$ cat /etc/postfix/main.cf | grep "Maildir"
home_mailbox = Maildir/

How does this enable me to filter email that is labeled "SPAM"?

billymayday 03-13-2008 10:35 PM

It was more to do with the procmail rule shown than the ability per se

carlosinfl 03-14-2008 10:57 AM

So when I enable that comment in my postfix main.cf file, I no longer get email.

Code:

mailbox_command = procmail -a "$EXTENSION"
Should I not be using this option in my main.cf for procmail filtering?

billymayday 03-14-2008 03:07 PM

That looks like the one

Which
Quote:

So when I enable that comment in my postfix main.cf file, I no longer get email.
stops you getting email? If you mean the Maildir one, then mail is being sent to ~/Maildir in maildir format


All times are GMT -5. The time now is 07:56 AM.