procmail
[Top] [All Lists]

Re: Help with recipes

1997-01-16 17:51:55
Charles Gagnon said, as Jim Dennis quoted him:

G> It gets a bit more complicated cause I'd like to add a comment in 
G> the body of the message mentionning the mail as been forwarded.

G> I'd like procmail to add the note part before forwarding the massage to
G> User2.  Is it possible and if yes, how?

Jim Dennis responded with an awk script and a suggestion to add a feature to
formail to prepend and append files to the body.

D>      Wouldn't that make alot of reply recipes easier?
D>      Couldn't you imaging some cool ":0f " recipes that
D>      would be quicker and easier this way?

There's a program already in existence that can do it.  Its name is

                                     cat

Yes, cat.  To append a file to the body,

  :0bf
  * conditions
  | cat - file

If the file did not already end with an empty line, procmail will add one
upon receiving the output of the filter.

To prepend a file to the body,

  :0hf
  * conditions
  | cat - file

That actually adds it after the blank line at the end of the head, so when
procmail receives the filter output and reattaches the old body, it sees
the file as the start of the body.

D>      Where do I "officially" send this as an enhancement
D>      request?  Anyone want to volunteer to write the code
D>      and submit the diffs (or do you want to trust my
D>      meager coding skills at it)?

Consider it already written.

Oh, and if you don't feel comfortable with using cat and filtering only part
of the message, there's another program you can try: it's called

                                 sed

To append a file to the body,

  :0f
  * conditions
  | sed $r file

To prepend a file to the body,

  :0f
  * conditions
  | sed -e '1,/^$/!b' -e '/^$/r file'

In either case, rewrites of formail and long awk scripts are unnecessary.

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