procmail
[Top] [All Lists]

Re: scoring

1997-06-02 10:03:00
Vincent Lefevre <Vincent(_dot_)Lefevre(_at_)ens-lyon(_dot_)fr> writes:
I've just started trying scoring methods...

How can I test if, e.g., there are more than 5 "$" characters in the
header?

Something like

:0 H
* -50^0
* 10^1 \$
Mail/junk

doesn't work and sends any mail in Mail/junk.

Ah, the dreaded 'leading backslash' problem.  If the first character in
the regexp part of the condition is a backslash, it's stripped.  The
above therefore has a regexp with a special (not a literal) dollarsign,
which will thus match end-o'-lines.  This stripping is so procmail can
distinguish, for example, the following:

        * < 1000
        * \< 1000

The first condition succeeds if the message is less than 1000 bytes long,
while the second succeeds if the headers of the message contains "< 1000".

The result of this is that if the first character of the desired regexp
is one of '<', '>', '?', '!', '\', or '$', then you have to protect it
somehow.  The recommended method is to place an empty pair of parens
before the regexp:

        # The 'H' was redundant
        :0
        * -50^0
        *  10^1 ()\$
        Mail/junk

Another solution exists in this case which is more readable:

        :0
        * -50^0
        *  10^1 [$]
        Mail/junk

Do you see why that works?


Where can I find examples?

The procmailsc(5) manpage is a good start.


Philip Guenther

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