procmail
[Top] [All Lists]

Re: Looping problem

2002-06-07 13:05:32
On  6 Jun, S Semple wrote:
|  I dont really understand the 
| * ! ^X-Loop: steve(_at_)DFAS(_dot_)com
| 
| I asume that I need it in the following recipe but cant get it to do what I 
want.
| 
| I asume that this is a looping problem, where do I put the X-Loop and what 
syntax do I use. I have tried to read up on it but I cant seem to find much in 
procmail, or procmailex. Or at least Ive missed it.
| 
| Here is part of the recipe.
| ####################
| 
| SUBJ_=`formail -xSubject: \
|        | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
| :0
| *  ! ^TO_steve(_at_)DFAS(_dot_)com
| 
| {
|   :0 fwh
|   | formail -I"Subject: NOT 2 STEVE-> ${SUBJ_}"
|   :0:
|   ! steve(_at_)DFAS(_dot_)com
| 
| 
| ########################
| 
| The problem is that when I test this in my "Sand box" It works. But when I 
put it into one of my rc.spam files with other recipies it gives me this out 
put.
| 
| ### BELOW IS MESSAGE, NOTE THE MANY "STEVE-> NOT 2"
| 
| Date: Thu, 6 Jun 2002 19:09:46 GMT
| From: Steve Night <steve(_at_)mailnet(_dot_)DFAS(_dot_)com>
| To: steve(_at_)DFAS(_dot_)com
| Subject: NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2
|     STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2
|     STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2
|     STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2
|     STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2 STEVE-> NOT 2
|     STEVE-> test6 one
| 
| ### Below is in the header of the message.
| 
| Return-Path: <steve(_at_)mailnet(_dot_)DFAS(_dot_)com>
| Received: (from steve(_at_)localhost)
|         by mailnet.DFAS.com (8.11.6/8.11.2) id g56J9t223374
|         for steve(_at_)DFAS(_dot_)com; Thu, 6 Jun 2002 19:09:55 GMT
| [snip more of same]

You're right. It is a loop. The condition that causes a match in the
outer block, is unchanged (i.e. still matches) when you forward the
mail after munging the Subject: header. Try something like:

:0
* ! ^TO_steve(_at_)DFAS(_dot_)com
* ! ^X-Loop: steve(_at_)DFAS(_dot_)com
* ^Subject:[    ]*\/[^  ].*
* MATCH ?? ^^\/.*[^     ]
{
  :0 fhw
  |formail -I"Subject: NOT 2 STEVE-> $MATCH" -A"X-Loop: 
steve(_at_)DFAS(_dot_)com"
  :0
  ! steve(_at_)DFAS(_dot_)com
}

Note there is no lock (:) on the forwarding recipe. That should be a
little more efficient "cleaning up" the Subject:, and prevent the loop.
It is a <space> and <tab> inside the 3 character classes.  Assuming
this this is all on the same machine (i.e. forwarding to 
steve(_at_)DFAS(_dot_)com
sends it right back to the same place), which seems likely because of
the loop, you can "simplify" that to:

:0 fhw
* ! ^TO_steve(_at_)DFAS(_dot_)com
* 1^0
* 1^0 ^Subject:[        ]*\/[^  ].*
* 1^0 MATCH ?? ^^\/.*[^         ]
|formail -I"Subject: NOT 2 STEVE-> ${MATCH:-no Subject}"

:0A:
$DEFAULT

The 3 scored conditions (beginning with 1^0) make sure the filter is
still run if there is no Subject: header.  You could also add a
lockfile to the first recipe, redirect the formail output to $DEFAULT,
and skip the last recipe.  I'm not personally fond of that construct
for some inexplicable reason.

Lastly, I don't use ^TO and ^TO_ myself, but that looks like correct
usage.

-- 
Reply to list please, or append "6" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


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