procmail
[Top] [All Lists]

Re: What's the difference?

1997-05-20 01:40:00
"Luke" == Luke Davis <ldavis(_at_)voicenet(_dot_)com> writes:

Luke> What's the difference between:
Luke> * ^from:.*daemon
Luke> and:
Luke> * ^from_daemon

The first will match a line starting with `from:', and containing
`daemon' later on. The second one will match on a line starting with
the text `from_daemon'. (By default, procmail matches are case
insensitive, so the text may be in uppercase.)

I think you want to know about the `^FROM_DAEMON' macro. This one
needs to be in uppercase. When procmail sees this macro, it will
expand it to a long regular expression (see man procmailex(5) for
details) that will match on messages sent by any kind of automated
process (a `daemon' in UNIX terminology).

Luke> Also between:
Luke> * ^tojack
Luke> and:
Luke> * ^to:.*jack

Again, I suspect you want ^TO in the first one.
`^tojack' will only match on a header in a very exceptional case: a line
starting with `tojack'.

`^to:.*jack' will match when `jack' is anywhere on the To: line. So it
will match for example:
To: jack(_at_)some(_dot_)where
To: mike(_at_)jackal(_dot_)com
To: jim(_at_)somewhere(_dot_)else(_dot_)edu, bigjack(_at_)your(_dot_)site

But it will not match on things sent Cc: to any of those addresses.

`^TOjack' will match for a message where the recipient contains jack.
(Or rather, a word starting with jack.)

^TO is a magical operator that will match on the To:, Cc:, Bcc: (note:
Bcc: is normally stripped from the mail.) lines (and a bunch of
others). It also ends in a particular regular expression that makes
sure the next thing is the start of a word.

If you have a recent version of procmail (3.11pre...), you might want
to use ^TO_.

Luke> Also, if I wanted to catch:
Luke> Bill Jackson <jack(_at_)nowhere(_dot_)edu>
I assume this string appears on the From: line

Luke> Would any of the following *not* work?:
Luke> ^fromjack
This will not work.
Luke> ^from:.*jack
This will.
Luke> ^from_bill
There is no ^FROM or ^FROM_ macro. `^From bill' might work if the text
also appears on the `From ' line.
Luke> ^from: bill jackson
This should work, unless there is extra whitespace on the line.
Better use: `^From:[    ]*bill[         ]*jackson
(There is a space and a tab between the brackets.)

Luke> Note: on the last, would rephrasing it to:

Luke> ^from: Bill Jackson*
Luke> Make any difference?
Rule one of regular expressions: Don't end one with a `*'.
This one will actually match a line starting with `From: Bill Jackso':
The `*' at the end says `match zero or more times the character before
it' (in this case, the `n').
Since there is nothing after it, procmail will match zero times.

-- 
Guy Geens <ggeens(_at_)iname(_dot_)com>
Home Page: http://www.elis.rug.ac.be/~ggeens
finger ggeens(_at_)elis(_dot_)rug(_dot_)ac(_dot_)be for PGP public keys (or use 
keyserver) 

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