Conditional procmail recipe involving whitelist From and Subject lines

Conditional procmail recipe involving whitelist From and Subject lines

am 01.09.2005 05:13:05 von dtcombucks

I want to create a procmailrc recipe that routes all mail with Subject:
lines "Re:" or "" ("") to folder spam-filter except any with
addresses on my whitelist on the From: line.

Can anyone help me?

It seems I could start by converting my whitelist to a variable, such
as:

WHITELIST=`(friend1|\
friend2|\
....
lastfriend)`

then some such recipes as:

:0
* ^Subject.*(Re:|$)
*!From:.*WHITELIST
$HOME/Spam-filter

:0
* $From.*WHITELIST
INBOX

Can anyone help me firm up the logic?

Thanks in advance,
Dwight Johnson

Re: Conditional procmail recipe involving whitelist From and Subjectlines

am 01.09.2005 06:40:11 von AK

dtcombucks wrote:

> I want to create a procmailrc recipe that routes all mail with Subject:
> lines "Re:" or "" ("") to folder spam-filter except any with
> addresses on my whitelist on the From: line.
>
> Can anyone help me?
>
> It seems I could start by converting my whitelist to a variable, such
> as:
>
> WHITELIST=`(friend1|\
> friend2|\
> ...
> lastfriend)`
>
> then some such recipes as:
>
:0
* ^Subject: (Re:|$)
* $ ! From:.*$WHITELIST
$HOME/Spam-filter
>
:0
* $ From.*$WHITELIST
INBOX
>
> Can anyone help me firm up the logic?
>
> Thanks in advance,
> Dwight Johnson
>

YOu used the shell meta ($) do decode a variable, but you forgot the $
infront of the varable WHITELIST

You might be better using sed to encode the list of friends in the white
list by reading it from a file.
TEST=`cat yourfile |sed -e 's/ /|/g'

yourfile will have the email address separated by space.

Then you can check
:0
* $ ^From: ($TEST)
INBOX

AK

Re: Conditional procmail recipe involving whitelist From and Subject lines

am 02.09.2005 21:17:37 von dtcombucks

I never find it necessary to use "$" inside a procmailrc file for
variable assignment

I like your external file idea.

My whitelist is too long to be assigned to an environment variable and
I don't know how to use sed. I am looking for something like:

:0
* ^From.*(`cat whitelist`)
INBOX

where whitelist is the name of a file containing my whitelist, but when
I try this, it doesn't expand the data in the whitelist file in place.
Instead, it seems to look for a match for `cat whitelist`.

Dwight

AK wrote:
> dtcombucks wrote:
>
> > I want to create a procmailrc recipe that routes all mail with Subject:
> > lines "Re:" or "" ("") to folder spam-filter except any with
> > addresses on my whitelist on the From: line.
> >
> > Can anyone help me?
> >
> > It seems I could start by converting my whitelist to a variable, such
> > as:
> >
> > WHITELIST=`(friend1|\
> > friend2|\
> > ...
> > lastfriend)`
> >
> > then some such recipes as:
> >
> :0
> * ^Subject: (Re:|$)
> * $ ! From:.*$WHITELIST
> $HOME/Spam-filter
> >
> :0
> * $ From.*$WHITELIST
> INBOX
> >
> > Can anyone help me firm up the logic?
> >
> > Thanks in advance,
> > Dwight Johnson
> >
>
> YOu used the shell meta ($) do decode a variable, but you forgot the $
> infront of the varable WHITELIST
>
> You might be better using sed to encode the list of friends in the white
> list by reading it from a file.
> TEST=`cat yourfile |sed -e 's/ /|/g'
>
> yourfile will have the email address separated by space.
>
> Then you can check
> :0
> * $ ^From: ($TEST)
> INBOX
>
> AK

Re: Conditional procmail recipe involving whitelist From and Subject lines

am 02.09.2005 23:04:20 von Allodoxaphobia

On 2 Sep 2005 12:17:37 -0700, dtcombucks wrote:
> I never find it necessary to use "$" inside a procmailrc file for
> variable assignment
>
> I like your external file idea.
>
> My whitelist is too long to be assigned to an environment variable and
> I don't know how to use sed. I am looking for something like:
>
>:0
> * ^From.*(`cat whitelist`)
> INBOX
>
> where whitelist is the name of a file containing my whitelist, but when
> I try this, it doesn't expand the data in the whitelist file in place.
> Instead, it seems to look for a match for `cat whitelist`.
>
> Dwight

Here's my Check-To-See-If-It-In-The-WhiteList recipe:
:
|WHITE = "No"
|:0
| * ? formail -rtzxTo: | fgrep -i -f $PMDIR/whitelist
| {
| WHITE = "Yes"
| }
:
I don't simply save the email at this point. The emails from whitelisted
addresses still are sorted into misc. folders -- by sender, by Subject:,
even by the who To:.

My whitelist is a simple, 1-line-at-a-time, bare-bones email addy file,
viz:
userid1@domane.nam
userid2@domane.nam
:
:
userid99@domane.nam

T'ain't my design. I re-hacked it and re-worked it for _my_ implementation
from:
http://www.xray.mpe.mpg.de/mailing-lists/procmail/1998-05/ms g00315.html

I have a script that runs at each login and it (re)creates my whitelist from
my (pine) .addressbook, all the To:'s in my existing (pine) sent-mail folders
(current, and all the e-o-m archived ones that I have hanging around in my
mail sub-dir.

WLAC!
HTH
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
Pueblo, Colorado | @ | Jonesy | OS/2 __
38.24N 104.55W | config.com | DM78rf | SK

Re: Conditional procmail recipe involving whitelist From and Subjectlines

am 03.09.2005 01:01:17 von Alan Clifford

On Thu, 31 Aug 2005, dtcombucks wrote:

d> I want to create a procmailrc recipe that routes all mail with Subject:
d> lines "Re:" or "" ("") to folder spam-filter except any with
d> addresses on my whitelist on the From: line.
d>
d> Can anyone help me?
d>

My test for not in the whitelist is as follows:

MARP_FROM=`formail -c -rtz -x To:`
MARP_DIR=${HOME}/.procmail/marp
MARP_WHITELIST=${MARP_DIR}/white.list

# Is it not in the whitelist?
:0
* ! ? echo "${MARP_FROM}" | grep -F -isx -f "${MARP_WHITELIST}"
{
# empty subject
:0 :
* ! ^Subject: .+
spam-filter

:0 :
* ^subject:.*re:
spam-filter
}

The white.list format is one address per line like this:

---------cut here-----------------------
This file should not be empty
alan@example.com
fred@com.example
sardines@purse-seine.net
lists@clifford.ac
---------cut here-----------------------


--
Alan

( If replying by mail, please note that all "sardines" are canned.
There is also a password autoresponder but, unless this a very
old message, a "tuna" will swim right through. )

Re: Conditional procmail recipe involving whitelist From and Subjectlines

am 03.09.2005 02:55:23 von AK

dtcombucks wrote:

> I never find it necessary to use "$" inside a procmailrc file for
> variable assignment
>
> I like your external file idea.
>
> My whitelist is too long to be assigned to an environment variable and
> I don't know how to use sed. I am looking for something like:
>
> :0
> * ^From.*(`cat whitelist`)
> INBOX
>
> where whitelist is the name of a file containing my whitelist, but when
> I try this, it doesn't expand the data in the whitelist file in place.
> Instead, it seems to look for a match for `cat whitelist`.
>
> Dwight
>
> AK wrote:
>
>>dtcombucks wrote:
>>
>>
>>>I want to create a procmailrc recipe that routes all mail with Subject:
>>>lines "Re:" or "" ("") to folder spam-filter except any with
>>>addresses on my whitelist on the From: line.
>>>
>>>Can anyone help me?
>>>
>>>It seems I could start by converting my whitelist to a variable, such
>>>as:
>>>
>>>WHITELIST=`(friend1|\
>>>friend2|\
>>>...
>>>lastfriend)`
>>>
>>>then some such recipes as:
>>>
>>
>>:0
>>* ^Subject: (Re:|$)
>>* $ ! From:.*$WHITELIST
>>$HOME/Spam-filter
>>
>>:0
>>* $ From.*$WHITELIST
>>INBOX
>>
>>>Can anyone help me firm up the logic?
>>>
>>>Thanks in advance,
>>>Dwight Johnson
>>>
>>
>>YOu used the shell meta ($) do decode a variable, but you forgot the $
>>infront of the varable WHITELIST
>>
>>You might be better using sed to encode the list of friends in the white
>>list by reading it from a file.
>>TEST=`cat yourfile |sed -e 's/ /|/g'
>>
>>yourfile will have the email address separated by space.
>>
>>Then you can check
>>:0
>>* $ ^From: ($TEST)
>>INBOX
>>
>>AK
>
>

Is the whitelist in the email1|email2|email3 format? If not, it will
only match if the contents of your whitelist are included on the From line .

try
F=`cat whitelist`
Pattern=`echo $F|sed -e 's/ /|/g'`

:0
* $ ? test -z "$Pattern"
* $ ^Mailer_From: ($Pattern)
INBOX

AK