W. Wesley Groleau wrote,
| I received several good suggestions that almost did it, but now I realize
| I was not clear in my description.
Well, what you said this time is exactly what I understood from the start:
you want to keep only the oldest Received: header for entry into your site
and those older (before the message got to your site) but none newer (as it
bounced around within your site).
| BTW, isn't it wierd that some Received headers 'continue' at the ID and
| others just run on without a break?
There's nothing weird: it depends on the configuration of the transport that
added the Received: line. (Look at the directly mailed copy of this message,
Wesley, for some Received: headers that are broken into four lines each.)
Anyhow, here's an idea; in your .procmailrc,
FWPAT='\<fw\.hac\.com' # no trailing \>
:0
* any other conditions for bothering in the first place, plus these two:
* 1^1 $ ^Received:.*$FWPAT\>
* -1^1
{
:0h
RXLINES=|formail -XReceived:
INCLUDERC = $HOME/.striprxrc
:0hfw
| formail -I Received: -X "" ; echo "$RXLINES" ; echo
}
and in $HOME/.striprxrc (or wherever you put it),
:0 # search area isn't H, so wrapping continuation lines is not automatic
* RXLINES ?? $ ()$FWPAT(\>.*)?$(.+$)*\/[A-Z0-9](.|$)*$FWPAT\>(.*$)*
{ RXLINES=$MATCH
INCLUDERC=$_ }
Two formails and a shell are a lot of forks (and it moves the surviving
Received: lines to the bottom of the head, but that should be no problem),
but it preserves the continuation lines' format.