Pike v8.1 release 6

Method MIME.Message()->create()


Method create

MIME.Message MIME.Message()
MIME.Message MIME.Message(string message)
MIME.Message MIME.Message(string message, mapping(string:string|array(string)) headers, array(object)|void parts)
MIME.Message MIME.Message(string message, mapping(string:string|array(string)) headers, array(object)|void parts, bool guess)

Description

There are several ways to call the constructor of the Message class:

  • With zero arguments, you will get a dummy message with neither headers nor body. Not very useful.

  • With one argument, the argument is taken to be a byte stream containing a message in encoded form. The constructor will analyze the string and extract headers and body.

  • With two or three arguments, the first argument is taken to be the raw body data, and the second argument a desired set of headers. The keys of this mapping are not case-sensitive. If the given headers indicate that the message should be of type multipart, an array of Message objects constituting the subparts should be given as a third argument.

  • With the guess argument set to 1 (headers and parts may be 0 if you don't want to give any), you get a more forgiving MIME Message that will do its best to guess what broken input data really meant. It won't always guess right, but for applications like mail archives and similar where you can't get away with throwing an error at the user, this comes in handy. Only use the guess mode only for situations where you need to process broken MIME messages silently; the abuse of overly lax tools is what poisons standards.

See also

cast()