procmail
[Top] [All Lists]

Re: this recipe generating a one-byte email message...

2001-12-30 13:28:55
Dave Vrona asked,

| I'm wondering if someone has an idea about the following recipe.  It works
| as intended except that it is also mailing me a one byte e-mail message.

| TAG = ""
| HEADERS = '^Subject:(.*\<)?'
|
| :0
| * $ ${HEADERS}test123
| {
|     TAG = "test message match"
| }
|
| :0cE
| * $ ${HEADERS}ALERT from SonicWALL
| {
|     TAG = "FORMAT SONICWALL USERID 12345678 TZ +00:00"
| }

OK, you have a `c' flag on a recipe that opens braces, so if the conditions
match -- if the subject didn't contain "test 123" (if it did, the `E' flag
would keep it away) and does contain "alert from sonicwall" -- you'll launch
a clone procmail.

In the clone, TAG is set to that string; in the parent procmail, TAG is
still null (again, the `E' flag keeps out messages where the previous braces
put text into TAG).

| # now, if TAG is set, insert it into the subject

TAG is always set at that point; however, it may or may not be null.

| :0 fw
| * !  TAG ?? ^^^^
| *   ^Subject: *\/[^ ].*
| | $FORMAIL -I "Subject: $TAG" | $SENDMAIL sonicwall(_at_)dshield(_dot_)org

Now we have two procmail processes working on identical messages; the clone
has text in TAG and the original has TAG empty.  So the clone matches
attempts the recipe and filters (you have an `f' flag on it) the message
through formail into $SENDMAIL.  $SENDMAIL doesn't write anything to stdout,
so the replacement message generated by the filter is empty; procmail adds a
trailing newline, giving you one byte.  Later recipes deliver that one-byte
message somewhere, or it gets to the end of your rcfile undelivered and goes
into $DEFAULT.

The original procmail process has no text in TAG, so it skips that recipe
and moves on.

My guess: you don't really want to clone procmail at all; rather you
probably want to send a copy to the other address and let later recipes
handle the original.  So take the `c' off the second set of braces and
change the `f' on the formail-into-sendmail recipe to a `c'.

I'm also not sure why you're extracting the subject; if you use the value of
$MATCH later in your rcfile, that's all the more indication that you want to
have a non-empty message and that you meant `c' rather than `f'.



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