procmail
[Top] [All Lists]

Re: Match X but not Y if is also there

2001-11-30 22:19:25
On 30 Nov, listuser(_at_)neo(_dot_)pittstate(_dot_)edu wrote:
| *sigh*  Well I feel dumb.  I wasn't even thinking of something as simple
| as that.  Here's what I'm using now.
| 
| #  --  broadwing.net
| :0c
| * ? formail -x"Received:" | egrep -is "broadwing.net"
| * ! ^X-Loop: $ABUSE
| * ! ? formail -x"Received:" | egrep -is "netzero.net"
| {
|         :0f
|         | formail -I"X-Spam: broadwing.net" \
|         -I"X-Loop: $ABUSE"
| 
|         :0:
|         /var/spool/mail/quarantine/spam/broadwing.net
| }
| #  --  broadwing.net
| 
| 
| I believe that's working.  I don't have a way to test that at the moment
| though.  Ironically I'm having a closely related problem trying to match
| my X-Loop header.  [...]

The problem with the X-Loop condition is you haven't told procmail it
needs to expand the variable so it's looking for a literal $ABUSE in the
the header instead of the value expanded from the variable.  Also, the
formail |egrep pipelines seem unnecessary.  I would think these 3
conditions should be sufficient:

* $ ! ^X-Loop: $ABUSE
*     ^Received:.*\<broadwing\.net\>
*   ! ^Received:.*\<netzero\.net\>

As far as testing it, you *must* have a way to test if other users
depend on it working. If it's just for you then I guess it doesn't
matter (as long as it's not an auto-reponder or bounce recipe). It's
been discussed frequently here over the years. For example, I just put
the following in a file named ".this".

DEFAULT=/dev/null
NL="
"
:0
*   ^Received:.*domain1
* ! ^Received:.*domain2
{ LOG = "Matched$NL" }

:0 E
{ LOG = "NO Match$NL" }

Then I took a test message and edited the headers a couple times to 
contain various combinations of Received: headers with domain1, domain2,
and domain3 and ran them through the rcfile.

With 1 domain1 and 2 domain3 Received: headers:

$ procmail ./.this <testmsg
Matched

[edited headers so there is now 1 each domain1, domain2, domain3]

$ procmail ./.this <testmsg
NO Match

When procmail did as I expected, I felt a little more comfortable making
the suggestion, though you should always test yourself. VERBOSE = yes
can be helpful if a simple "Match" or "NO Match" isn't helpful enough
(e.g. testing scored recipe).  Try it, you'll like it. ;-)

-- 
Reply to list please, or append "6" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


_______________________________________________
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>