procmail
[Top] [All Lists]

Re: Delete all the Received: headers

1997-08-07 22:37:00
Mitsuru Furukawa wrote,

| Please help me to construct a recipe which
| deletes all the Received: header lines
| and add "X-Received: Deleted all the Received headers"
| before forwarding.
| 
| I began by something like this
|   :0fH
|    | sed -e '/^Received:.*$//g'
| which seems to delete as almost expected but I'm stuck from there...

First, that would not delete lines but rather it would leave empty lines
where Received: headers began; second, many Received: headers (more so than
any other) are continued onto additional lines, so the continuation lines
would still be there.

Second, `h' would help there but `H' has no effect.

The filtering recipe you need is this:

    :0fh
    | formail -IReceived: -A"X-Received: Deleted all the Received headers"

but last, I'm not sure you really should delete them anyway; they carry
tracing information that could be invaluable.  (Having said that, I'll
confess to deleting Received: headers some of the time, but only in
reprocessing mail that I have already read, never from incoming mail
before I see it.)

| BTW, I have a feeling that the flag H has more significance than
| just "Egrep the header". 
| That is because if I use h flag, header and body are fed as body
| and if I use H flag, header and body are fed as header in mailbox.
| Am I wrong?

I'm not sure what you're saying, Mitsuru, so I'll try to explain the
difference in my own words:

`H' and `B' tell procmail which part of the message to use in the condition
lines (usually, which part to search for the regexps).  The default is `H';
to search the entire message, you need to specify `HB' or `BH'.  Also, they
can be overridden for single conditions by using the VAR ?? syntax.

`h' and `b' tell procmail which part to use in the action line.  If the
action is a filter, and you use only `h' or `b', the other part will be
reattached unchanged.  If the action is a save to a folder or a pipe to a
command and there is no `c' flag, and you use only `h' or `b', the other
part will be dropped silently.  The default is `hb' if you don't specify.

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