Index: library/Zend/Mime.php =================================================================== --- library/Zend/Mime.php (revision 23462) +++ library/Zend/Mime.php (working copy) @@ -127,33 +127,43 @@ $lineEnd = self::LINEEND) { $out = ''; - $str = self::_encodeQuotedPrintable($str); - - // Split encoded text into separate lines - while ($str) { - $ptr = strlen($str); - if ($ptr > $lineLength) { - $ptr = $lineLength; - } - - // Ensure we are not splitting across an encoded character - $pos = strrpos(substr($str, 0, $ptr), '='); - if ($pos !== false && $pos >= $ptr - 2) { - $ptr = $pos; - } - - // Check if there is a space at the end of the line and rewind - if ($ptr > 0 && $str[$ptr - 1] == ' ') { - --$ptr; + + if (function_exists('quoted_printable_encode')) { + // Only available in PHP 5.3 or greater + $out = quoted_printable_encode($str); + } elseif (function_exists('imap_8bit')) { + // Requires IMAP Module + $out = imap_8bit($str); + } else { + $str = self::_encodeQuotedPrintable($str); + + // Split encoded text into separate lines + while ($str) { + $ptr = strlen($str); + if ($ptr > $lineLength) { + $ptr = $lineLength; + } + + // Ensure we are not splitting across an encoded character + $pos = strrpos(substr($str, 0, $ptr), '='); + if ($pos !== false && $pos >= $ptr - 2) { + $ptr = $pos; + } + + // Check if there is a space at the end of the line and rewind + if ($ptr > 0 && $str[$ptr - 1] == ' ') { + --$ptr; + } + + // Add string and continue + $out .= substr($str, 0, $ptr) . '=' . $lineEnd; + $str = substr($str, $ptr); } - - // Add string and continue - $out .= substr($str, 0, $ptr) . '=' . $lineEnd; - $str = substr($str, $ptr); + + $out = rtrim($out, $lineEnd); + $out = rtrim($out, '='); } - - $out = rtrim($out, $lineEnd); - $out = rtrim($out, '='); + return $out; }