procmail
[Top] [All Lists]

RE: Fixing up broken headers how?

2001-12-26 12:35:56
Thinking over your problem of splitting out remailed news articles further,
it may be that the "digest split" mode isn't quite what the doctor ordered.
For example, if the embedded news article in turn contains copies or
fragments of mail headers, then "digest split" will break those messages out
as separate messages, and this may be what you want.  Something more low
tech. may be the way to go: (1) delete the header, (2) remove the leading
":" (although perhaps it isn't in your original message but was introduced
when you edited it, (3) run formail on the result to create a proper "From_"
line.  Here's how this might look in a recipe (disclaimer: don't use this
without testing it):

:0 fbhw
* ^From:(_dot_)*(_at_)news(_dot_)palmos(_dot_)com
| sed -e '1,/^$/d' | sed -e '1,/^From: / {/^From: / \!d \
}' | formail

1. The first sed command strips off the initial header
2. The second sed command strips off everything in the body up to (but not
including) the first "From: " line. Note - these two sed commands cannot
easily be combined into one.
3. The simple invocation of "formal" adds a mailbox conformant "From_" line.

For the purposes of testing, I tried this out, by copying the following
lines to a file named "tst.rc":

---- begin ----
SENDMAIL=
DEFAULT=|
LOGFILE=./tst.log

:0 fbhw
* ^From:(_dot_)*(_at_)news(_dot_)palmos(_dot_)com
| sed -e '1,/^$/d' | sed -e '1,/^From: / {/^From: / \!d \
}' | formail
---- end ---

and then ran this command:
   procmail tst.rc < tst.mail

Here's the output:

---- begin ----
 From someone(_at_)suneidesis(_dot_)com  Wed Dec 26 11:22:35 2001
 From: "original author " <someone(_at_)suneidesis(_dot_)com>
 Newsgroups: tools-forum
 Subject: Re: source code for Palm OS 4.0 Note Pad app' available?
 Date: Tue, 25 Dec 2001 00:37:39 -0500

 This is the body of re-mailed news article.

---- end ----

(I've indented the output above by one space, to keep the mail program from
quoting it with a leading ">".)

My guess is that this final result is closer to what you're looking for, and
doesn't have the dangers of formail's "digest split" mode attempting to
create mail messages where they shouldn't exist.










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