/** * Splits the full email into headers and body * * @param string $message The full email message * @param boolean $unfold If headers should be unfolded * @return array An array containing the headers and body */ public static function splitHeaderBody($message, $unfold = true) { if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $message, $match)) { return array($unfold ? Mail_Helper::unfold($match[1]) : $match[1], $match[2]); } return array(); }