Mailfromd Manual (split by node):   Section:   Chapter:FastBack: Library   Up: Library   FastForward: Using MFL Mode   Contents: Table of ContentsIndex: Concept Index

5.8 Body Modification Functions

Body modification is an experimental feature of MFL. The version 8.7 provides only one function for that purpose.

Built-in Function: void replbody (string text)

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.

Built-in Function: void replbody_fd (number fd)

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

Mailfromd Manual (split by node):   Section:   Chapter:FastBack: Library   Up: Library   FastForward: Using MFL Mode   Contents: Table of ContentsIndex: Concept Index