You are here

function mimemail_parse_content in Mime Mail 5

Same name and namespace in other branches
  1. 6 mimemail.inc \mimemail_parse_content()
  2. 7 includes/mimemail.incoming.inc \mimemail_parse_content()
2 calls to mimemail_parse_content()
mimemail_parse in ./mimemail.inc
mimemail_parse_attachment in ./mimemail.inc

File

./mimemail.inc, line 439

Code

function mimemail_parse_content($part) {
  $content = $part['body'];

  // Decode this part
  if ($encoding = strtolower($part['headers']['Content-Transfer-Encoding'])) {
    switch ($encoding) {
      case 'base64':
        $content = base64_decode($content);
        break;
      case 'quoted-printable':
        $content = quoted_printable_decode($content);
        break;
      case '7bit':

        // 7bit is the RFC default
        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]);

    //$content = iconv($m[1], 'utf-8', $content);
  }
  return $content;
}