function mimemail_parse_headers in Mime Mail 6
Same name and namespace in other branches
- 5 mimemail.inc \mimemail_parse_headers()
- 7 includes/mimemail.incoming.inc \mimemail_parse_headers()
1 call to mimemail_parse_headers()
File
- ./
mimemail.inc, line 516 - Common mail functions for sending e-mail. Originally written by Gerhard.
Code
function mimemail_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(drupal_substr($row, 0, $split));
$val = trim(drupal_substr($row, $split + 1));
$headers[$name] = $val;
}
$type = preg_replace('/\\s*([^;]+).*/', '\\1', $headers['Content-Type']);
return array(
'headers' => $headers,
'body' => $body,
'content-type' => $type,
);
}