procmail
[Top] [All Lists]

Re: putting header fields into a set order (was a few other things)

2001-08-10 07:39:34
"David W. Tamkin" wrote:

Marco wrote,

| I have just found by myself the solution to this:
|
|
http://www.procmail.org/jari/pm-tips-body.html#modifying_shuffling_headers_a
lways_to

The stuff there looks messy, with the improper use and unpredictable results
of trying to put two extractors into the same regexp.
..........................

At this point, considering that I'm quite good at Perl scripting, and
much, much
less at using formail/procmail, and that all the messages left to sort
have passed
through formail at least once, what about a quick and dirty Perl script
which:

        1) reads one message at a time from the mailbox file
                (using "empty_line_immediately followed by From" as record 
separator

        2) puts all headers (= all lines from the beginning to the first empty
line)
           into an Hash

        3) Prints out the Hash Elements in a given order

        4) Prints whatever else is left (body, all possible attachments,
whatever)

Being good at Perl, this looks much faster and reliable to me in this
case where I
have to do it on an already existing mailbox, and of course I'd be happy
to post the final script here. The only things still stopping me is my
poor knowledge of email
formats and formail/procmail internals.

Can I safely assume that, after passing trhough formail as described in
the original thread, the perl regexp outlined above will safely pick one
message at a time?
What about my strategy about picking up the headers?

Last but not least, some messages differ only because one has:

Status: R0

and the second has:

Status: O

I guess this means it's the same message, (O)ld in both mailboxes, but
replied to
only in the first. Am I correct? If yes, can I safely ignore overwrite
it with
"Status: O"?

Note that if all this works safely (as in "it won't destroy messages if
done well")
then it also deleting unwanted headers as asked on this list last month
becomes
very easy.

Any feedback is welcome.

                                Ciao,
                                        Marco Fioretti
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail