extracting body of a message
am 29.12.2007 21:56:25 von siva.misra
Mail gurus:
I am looking for examples as to how I can extract certain parts of
mail message body using perhaps procmail.
For example if I receive a email containing just a single word in the
body, I want to have the procmail echo that word so that it can be fed
as stdin to a script via pipe.
Any help or suggestions will be much appreciated.
Thanks
Siva
Re: extracting body of a message
am 30.12.2007 09:32:06 von Garen Erdoisa
siva.misra@gmail.com wrote:
> Mail gurus:
>
> I am looking for examples as to how I can extract certain parts of
> mail message body using perhaps procmail.
> For example if I receive a email containing just a single word in the
> body, I want to have the procmail echo that word so that it can be fed
> as stdin to a script via pipe.
>
> Any help or suggestions will be much appreciated.
>
> Thanks
> Siva
--------
Procmail Example 1:
# The $$ string expands to the current process ID.
TEMPFILENAME="${HOME}/message.body.tmp.$$"
# Extract a copy of the message body in the pipeline to a file
:0 cb
${TEMPFILENAME}
# Note the backticks that launch an embedded script. The output
# of the script will be stored in the BUFFER procmail variable.
# Also note that the buffer variable has a max limit of 60000
# characters, which can be an issue if you are looking at a large
# message body depending on what your custom script does.
LINEBUF=60000
BUFFER=`cat ${TEMPFILENAME} |somescript ; rm -f ${TEMPFILENAME}`
---------
Procmail Example 2:
# Feed a message body to an embedded script
# This method uses formail to extract the message body
# by surpressing all the message headers and avoids having
# to create a temporary file. However the same issue with
# the message body size remains.
LINEBUF=60000
BUFFER=`formail -I "" |somescript`
--
Garen