/** * Creates a new message by parsing a string containing a complete mail * message. The headers are parsed and stored; the body is left intact. * * \param $data * A string with a complete mail message * * \return * A new AnewtMailMessage instance */ public static function from_string($data) { /* Sanity check */ assert('is_string($data)'); /* New message */ $message = new AnewtMailMessage(); /* Split headers from body */ list($headers, $body) = preg_split('/\\n{2,}/', $data, 2); /* Parse headers and body */ $message->parse_headers($headers); $message->parse_body($body); /* Parsed messages should not be sent out again (well, not without * explicit telling that they should be) */ $message->set('can-send', false); /* Return the message */ return $message; }