procmail
[Top] [All Lists]

Re: Rule not being honored. Why?

2009-02-10 14:00:49
On Tue, Feb 10, 2009 at 12:34:51PM -0600, Christopher L. Barnard wrote:

I forced this by sending a test message.  Yes, I could force this by
rerunning the message as well.  Dumping the full message headers
indicate that the From: line does in fact have a single space after it:

Yes, and 99% of all email does.  But that's irrelevant to whether
you should code for robustness and corner cases or risk being
perplexed for days when they crop up and you don't easily see what
went wrong.

From: root on nbmaster001 
<root(_at_)rudun-nbmaster001(_dot_)cc1(_dot_)rush(_dot_)edu>

I have modified my rule to honor both the From_ and From: line.  It is
the From: I am talking about; if I do not tell my mailer to explicitly
dump the headers it writes the 'From: ' as 'From '.

No, that's not what's happening.  The procmail log's abstract
shows the From_ line.  But procmail sees the entire message and
acts as you direct it to in the condition lines (which default to
parsing only the header).

:0:
* ^From[$WS]*root(_at_)rudun-nbmaster002\(_dot_)cc1\(_dot_)rush\(_dot_)edu

That will not work.

You need the '$' expansor when you use a var in the condition
like that.  (I did have one in my example condition line.)

  * $ ^From[$WS]*root(_at_)rudun-nbmaster002\(_dot_)cc1\(_dot_)rush\(_dot_)edu

But actually, in the From_ line (as opposed to the other
fields in the header), there will *always* be at least
one space after the leading word "From".  (And on many
systems there are two spaces there.)  So if you're going
to match on the From_ header, you could just do it like this:

  * ^^From +root(_at_)rudun-nbmaster002\(_dot_)cc1\(_dot_)rush\(_dot_)edu

Notice that I now have two leading carets.  That's because the
From_ line is the first line in the header.  We now won't need
to evaluate the rest of the header line-by-line if it's not the
expected email.


* ^Subject[$WS]*L700 NetBackup

I did not say to get rid of the colon here.  This will never
match for at least two reasons.  The first reason is as above:
you need the '$' expansor.

The second reason is that there will never be a line in the
header that starts "Subject" and then has zero or more whitespace
chars and then has some other text to include whitespace.

Try:

  * $ ^Subject:[$WS]*L700 NetBackup


Take Sean's advice and test your code when you are writing
it.  There is no reason to wait for more messages to come in.

You don't actually need to download any sandbox template, though
of course it's just fine if you do.  But you can just run, on the
command line:

   procmail -m DEFAULT=/dev/null VERBOSE=y test-rcfile < test-message


There are various common-sense caveats such as not having the
test-rcfile deliver to the test-message, not having the test-rcfile
do things such as send actual email out to someone in the real world,
etc., but if you use your head you should recognize such things on
your own.

So it looks like the From: line of the message should match the rule
exactly, but it still thinks there is no match...

See above.

Dallman
____________________________________________________________
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>