function messaging_htmlmail_parse_headers in Messaging 7
File
- messaging_htmlmail/
messaging_htmlmail.inc, line 515 - Drupal Messaging Framework - Send_Method class file
Code
function messaging_htmlmail_parse_headers($message) {
// Split out body and headers
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $message, $match)) {
list($hdr, $body) = array(
$match[1],
$match[2],
);
}
// Un-fold the headers.
$hdr = preg_replace(array(
"/\r/",
"/\n(\t| )+/",
), array(
'',
' ',
), $hdr);
$headers = array();
foreach (explode("\n", trim($hdr)) as $row) {
$split = strpos($row, ':');
$name = trim(substr($row, 0, $split));
$val = trim(substr($row, $split + 1));
$headers[$name] = $val;
}
$type = preg_replace('/\\s*([^;]+).*/', '\\1', $headers['Content-Type']);
return array(
'headers' => $headers,
'body' => $body,
'content-type' => $type,
);
}