procmail
[Top] [All Lists]

Re: Newbie needs help

2003-02-06 05:39:59
At 13:41 2003-02-05 -0800, Paul Tram did say:
Hello!

I have been using a shell accounts on Linux machines for some years now
but haven't gotten into Procmail until recently.

I was wondering if one of you could help me with a problem.

Let's say I want allow only certain people to contact me via a particular
email account.

In my .procmailrc file, I wrote:



:0:
* 
!(^From:(_dot_)*email1(_at_)hotmail(_dot_)com|^From:(_dot_)*email2(_at_)hotmail(_dot_)com|\
^From:(_dot_)*email3(_at_)yahoo(_dot_)com|^From:(_dot_)*somebody(_at_)yahoo(_dot_)com|\
^From:(_dot_)*friend(_at_)aol(_dot_)com|^From:(_dot_)*friend(_at_)hotmail(_dot_)com|\
^From:(_dot_)*brother(_at_)serv(_dot_)net|^From:(_dot_)*sister(_at_)qwest(_dot_)net|\
^To:(_dot_)*procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE|^Subject:.*[CyberDojo]|\
^From:(_dot_)*(_at_)somemailinglist(_dot_)com)
Spam

icko. Simplify - even if you don't combine ISP domain references into parenthetical groups:

* ! 
^From:.*(friend(_at_)aol\(_dot_)com|brother(_at_)serv\(_dot_)net|sister(_at_)qwest\(_dot_)net|\
        (email1|email2|friend)@hotmail\.com|(email3|somebody)@yahoo\.com|\
        @somemailinglist\.com)

(there's a LOT more optimization which could be performed on the above - all that could be expressed on two lines).

You can specify three separate condition lines (one for each header). Don't forget to escape dots - they have special meaning as a wildcard, and you should get into the habit of always escaping them when you mean them to be a real dot. Likewise, '[]' have special meaning as a character class encapsulation.

:0:
* ! 
^From:.*(email1(_at_)hotmail\(_dot_)com|email2(_at_)hotmail\(_dot_)com|email3(_at_)yahoo\(_dot_)com|\
        
somebody(_at_)yahoo\(_dot_)com|friend(_at_)aol\(_dot_)com|friend(_at_)hotmail\(_dot_)com|\
        
brother(_at_)serv\(_dot_)net|sister(_at_)qwest\(_dot_)net|@somemailinglist\.com)
* ! ^To:(_dot_)*procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de
* ! ^Subject:.*\[CyberDojo]
Spam

Each condition line is ANDed, requiring that the previous one resolved TRUE, but since you're operating on an inversion (! = NOT), "not these AND not these AND not these" is the same as NOT (this OR this OR this). A match on any of them would fail the NOT condition, whether they're or'ed collectively or and'ed separatley.


FTR, the expression for procmail isn't optimal - you should use any of the special list headers which are present on list-delivered messages (and if you're retaining list-delivered ones, then you shouldn't have to worry about ditching cc'ed copies to you, since you'll still get the message FROM the list - not to mention that ^To: won't catch instances where the list is addressed on a Cc: or even Bcc:). Likewise, the cyberdojo list should have some similar headers.

Procmail for instance has the following which uniquely identifies a message as having been delivered through the list:

X-BeenThere: procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE

Although I use the Sender: header myself.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>