function mimemail_parse_content in Mime Mail 7
Same name and namespace in other branches
- 5 mimemail.inc \mimemail_parse_content()
- 6 mimemail.inc \mimemail_parse_content()
Return a decoded MIME part in UTF-8.
2 calls to mimemail_parse_content()
- mimemail_parse in includes/
mimemail.incoming.inc - Parses a message into its parts.
- mimemail_parse_attachment in includes/
mimemail.incoming.inc - Convert a MIME part into a file array.
File
- includes/
mimemail.incoming.inc, line 168 - Functions that handle inbound messages to mimemail.
Code
function mimemail_parse_content($part) {
$content = $part['body'];
// Decode this part.
if ($encoding = drupal_strtolower($part['headers']['Content-Transfer-Encoding'])) {
switch ($encoding) {
case 'base64':
$content = base64_decode($content);
break;
case 'quoted-printable':
$content = quoted_printable_decode($content);
break;
// 7bit is the RFC default.
case '7bit':
break;
}
}
// Try to convert character set to UTF-8.
if (preg_match('/.*charset="?([^";]+)"?.*/', $part['headers']['Content-Type'], $m)) {
$content = drupal_convert_to_utf8($content, $m[1]);
}
return $content;
}