Next: , Previous: , Up: Library   [Contents][Index]

5.12 Body Modification Functions

Body modification is an experimental feature of MFL. The version 9.0 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.


  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
  # Open the temporary file
  set fd tempfile()

prog body
  # Write the body to it.
  write_body(fd, $1, $2)

prog eom
  # Use the resulting stream as the stdin to the mailproc
  # command and read the new body from its standard output.
  replbody_fd(spawn("</usr/bin/mailproc", fd))