Next: Message modification queue, Previous: Header modification functions, Up: Library [Contents][Index]
Body modification is an experimental feature of MFL. The version 9.0 provides only one function for that purpose.
Replace the body of the message with text. Notice, that text must not contain RFC 822 headers. See the previous section if you want to manipulate message headers.
Example:
replbody("Body of this message has been removed by the mail filter.")
No restrictions are imposed on the format of text.
Replaces the body of the message with the content of the stream fd. Use this function if the body is very big, or if it is returned by an external program.
Notice that this function starts reading from the current position in
fd. Use rewind
if you wish to read from the beginning of
the stream.
The example below shows how to preprocess the body of the message using external program /usr/bin/mailproc, which is supposed to read the body from its standard input and write the processed text to its standard output:
number fd # Temporary file descriptor
prog data
do
# Open the temporary file
set fd tempfile()
done
prog body
do
# Write the body to it.
write_body(fd, $1, $2)
done
prog eom
do
# Use the resulting stream as the stdin to the mailproc
# command and read the new body from its standard output.
rewind(fd)
replbody_fd(spawn("</usr/bin/mailproc", fd))
done