procmail
[Top] [All Lists]

Re: formail on the body not the header

1999-07-27 13:41:11
On Tue, 27 Jul 1999 02:04:57 -0400 (EDT), Ariel 
<asprocmail(_at_)dsgml(_dot_)com>
wrote:
I'm using :0fbw to add a line to the body of the message before saving it.
echo "message" > .file (ahead of time)
:0fbw
| cat .file -
(Suggestions for better command? Particularly one that doesn't need an
external file?)

You can embed the data in a string and then echo it back, but it will
be a bit cumbersome. I've been using sed for this occasionally:

    MESSAGE='\
Multi-line message I like to\
interpolate into the forwarded\
message using sed\
'
    :0fbw
    | sed 1i"$MESSAGE"

sed's hunger for trailing backslashes is annoying, especially since
getting those to stay put is a hassle (given that Procmail also has
quite an appetite for them, and will eat some before sed gets a chance
if you put them directly in the action line. The double-quoted
variable lets you smuggle those backslash-newline pairs past Procmail;
if you like, you can experiment with putting the message directly on
the action line, and try to figure out how many backslases you need,
but it's not really worth the trouble unless you have very special
needs, or are very bored).

When finding the mime part, it should take a parameter of the
content-type you are looking for and then the sequence number, to
find the frist, second, etc part of the message with the type
(default text/plain, 0).

formail is perhaps not the best tool for this. Granted, it would be
nice if it grokked MIME better, but I think a little set of Procmail
recipes is probably a better way to do "advanced" stuff like what
you're asking about.

I've been toying with something to split multiparts, running each
through a set of Procmail recipes, and assembling the whole thing back
together. It's not exactly foolproof, but the Procmail part isn't all
that hard, if you can keep track of your temp files etc. (Probably
it's better to write the assembler/disassembler driver in something
like Perl, but if you then pass each body part and the user's recipe
file to Procmail, you have a pretty powerful MIME engine.)

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

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