procmail
[Top] [All Lists]

Re: MATCH operator and (!) not symbol

2007-12-15 12:41:22
At 12:54 2007-12-15 -0600, reader(_at_)newsguy(_dot_)com wrote:
Can the match operator (\/) be used in a NOT recipe?

Example:
  :0
   * ! ^\/(To|Cc):.*(harryp|reader|bobbiep)@(reader|newsguy)\.

How can I capture lines that match that recipe?

Er, capture lines that DON'T match?  I don't get it.  Those are TWO headers 
you're checking anyway, so which header do you want to catch the non-match in?

The above inverted match works fine - if a header doesn't match, it'll be a 
TRUE condition (though of course, MATCH will be empty).

You can always use zero scoring to perform the initial match, then check to 
see if it is empty or not:

   :0
    * 0^0 ^\/(To|Cc):.*(harryp|reader|bobbiep)@(reader|newsguy)\.
    * ! MATCH ?? ^^^^

Alternately, you could capture the To: or Cc: to a MATCH, *THEN* perform a 
regexp check for the specific addresses.  but doing so would require that 
you perform the check twice - once for each of the two headers.


I think since the recipe is saying NOT to match the regex then
procmail takes it at its word and doesn't assign the line to $MATCH

Are you asking for whatever doesn't match?  The following is wholly untested:

:0
* 0^0 ^\/To:.*
* ! MATCH ?? (harryp|reader|bobbiep)@(reader|newsguy)\.
{
         BADRECEIPTS="${MATCH}"
}

# logic here would be that it's only TRUELY a bad recipient
# message if the previous rule also matched
:0A
* 0^0 ^\/Cc:.*
* ! MATCH ?? (harryp|reader|bobbiep)@(reader|newsguy)\.
{
         BADRECEIPTS="${BADRECEIPTS}${NL}${MATCH}"
}

:0
* BADRECEIPTS ?? ^^^^
{
         # no bad recipient fields.
}

The actual section from .procmailrc so you can see what the log output
is refering to:
[snip]

FTR, you didn't include any example header lines from the message in 
question, so how are we to evauate whether things appeared to run correctly?

---
  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 homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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