procmail
[Top] [All Lists]

Re: Extracting the message body

2001-07-27 05:04:05
Andrew suggested to Odhiambo,

H> I just deliver the message to '| formail -I "" > /some/file/somewhere'. I
H> don't know if this is the best way, but it works for me.

That's the hard way ... especially because Odhiambo wants to *append* the
body of the current message to the file ... because it requires two forks:
one to run a shell to handle the redirection, and another to run formail.

 :0B:
 * conditions
 file

To append a copy of the body to that file and deliver the original of the
message per later recipes (or to let it go to $DEFAULT), include a `c' flag
as well as `B'.

In fact, Odhiambo had asked,

W> If I could insert some separator before appending it, the better.

There would be a blank line at the end (and therefore the one at the end of
the body from the last message appended to that file, putting it at the
beginning of the current one); is that enough?  If not, it could be done
either with some forks or Don Hammond's trick of temporary reassigning
LOGFILE (with a regional LOCKFILE, of course):

 :0
 * conditions
 {
  LOCKFILE=filename$LOCKEXT

  oldVERBOSE=$VERBOSE
  VERBOSE=off
  oldLOGFILE=$LOGFILE

  LOGFILE=filename
  LOG="
- - - - - - -
" # note trailing quote on next line down

  LOGFILE=$oldLOGFILE # move logging back to the real logfile
  VERBOSE=$oldVERBOSE

  # add `c' if appropriate, as explained above
  :0B # no local lock because regional lock does both jobs
  filename

  # In case there was a `c',
  LOCKFILE
 }


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