You are here

function mimemail_parse_content in Mime Mail 6

Same name and namespace in other branches
  1. 5 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 541
Common mail functions for sending e-mail. Originally written by Gerhard.

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;
      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]);
  }
  return $content;
}