procmail
[Top] [All Lists]

Re: remove all headers except Subject, To ?

1998-01-12 15:58:00
On Mon, 12 Jan 1998, Calle Aasman wrote:

what I want to do is remove all stuff, so the result would be something
like: 

From: asdas(_at_)asdsa(_dot_)se
Subject: hi

message

From: asdas(_at_)asdsa(_dot_)se
Subject: hello

another message

One could use formail to strip out specific unwanted header fields, but
this gets tedious due to the infinite number of possible header fields. I
would do it something like this:

Use formail to get the header fields you want to keep. Then use formail in
a filtering recipe to rewrite the entire header. You'll probably want more
than "From:" and "Subject:", especially the 'postmark' line, since MUAs
need it to know where the begining of a new mail is. And if you don't keep
the date, it may show annoyingly as "xxx" in your index. Some
experimentation may be required to get exactly what you want.

        from_="`head -1`"
        date=`formail -X'Date:'`
        from=`formail -X'From:'`
        subject=`formail -X'Subject:'`

        :0fhiw
        | echo "$from_" | formail -A"$date" -A"$from" -A"$subject"

Additionally, you may need to keep other header fields, too, such as
"MIME-Version:", or some other header field important to your MUA.

David Hunt


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