/** * Encode header fields * * Encodes header content according to RFC1522 if it contains non-printable * characters. * * @param string $value * @return string */ protected function _encodeHeader($value) { if (\Zend_Mime::isPrintable($value)) { return $value; } else { /** * Next strings fixes the problems * According to RFC 1522 (http://www.faqs.org/rfcs/rfc1522.html) */ $quotedValue = ''; $count = 1; for ($i = 0; strlen($value) > $i; $i++) { if ($value[$i] == '?' or $value[$i] == '_' or $value[$i] == ' ') { $quotedValue .= str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $value[$i]); } else { $quotedValue .= $this->encodeQuotedPrintable($value[$i]); } if (strlen($quotedValue) > $count * \Zend_Mime::LINELENGTH) { $count++; $quotedValue .= "?=\n =?" . $this->_charset . '?Q?'; } } return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } }
/** * Encode header fields * * Encodes header content according to RFC1522 if it contains non-printable * characters. * * @param string $value * @return string */ protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { $base64Value = base64_encode($value); return "=?" . $this->_charset . "?B?" . $base64Value . "?="; } }
public function getBodyHtml($htmlOnly = false) { if ($htmlOnly) { return parent::getBodyHtml(true); } $mime = new Zend_Mime($this->getMimeBoundary()); $boundaryLine = $mime->boundaryLine($this->EOL); $boundaryEnd = $mime->mimeEnd($this->EOL); $html = parent::getBodyHtml(); $text = parent::getBodyText(); $text->disposition = false; $html->disposition = false; $body = $boundaryLine . $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine . $html->getHeaders($this->EOL) . $this->EOL . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd; $mp = new Zend_Mime_Part($body); $mp->type = Zend_Mime::MULTIPART_ALTERNATIVE; $mp->boundary = $mime->boundary(); return $mp; }
/** * Encode header fields * * Encodes header content according to RFC1522 if it contains non-printable * characters. * * @param string $value * @return string */ protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { $quotedValue = Zend_Mime::encodeQuotedPrintable($value, 400); $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue); return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } }
protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { $quotedValue = Zend_Mime::encodeQuotedPrintable($value); $quotedValue = str_replace(array('?', ' '), array('=3F', '=20'), $quotedValue); $quotedValue = rawurlencode($quotedValue); $quotedValue = str_replace('%3D%0A', '', $quotedValue); $quotedValue = rawurldecode($quotedValue); $quotedValue = '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } return $quotedValue; }
public function indexAction() { $this->_helper->viewRenderer->setNoRender(); //$value = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩъыьЭЮЯ'; $value = 'いろはにほへとちりぬるをわかよたれそつねならむ'; echo "<pre>B-1. Zend_Mime::encodeBase64Header:<br>\r\n"; echo Zend_Mime::encodeBase64Header($value, $this->_charset, $this->_len, $this->_feed); echo "\r\n<br><br>"; echo "Q-1. Zend_Mime::encodeQuotedPrintableHeader:<br>\r\n"; echo Zend_Mime::encodeQuotedPrintableHeader($value, $this->_charset, $this->_len, $this->_feed); echo "\r\n<br><br>"; mb_internal_encoding($this->_charset); echo "B-2. Base64 by mb_encode_mimeheader:<br>\r\n"; echo mb_encode_mimeheader($value, $this->_charset, 'B', $this->_feed, $this->_len); echo "\r\n<br><br>"; echo "Q-2. QuotedPrintable by mb_encode_mimeheader:<br>\r\n"; echo mb_encode_mimeheader($value, $this->_charset, 'Q', $this->_feed, $this->_len); echo "</pre>\r\n"; }
/** * set part type and disposition (with name if available) * * @param string $type * @param string $name */ public function setTypeAndDispositionForAttachment($type, $name = NULL) { $this->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; $partTypeString = $type; if ($name) { $name = Zend_Mime::encodeQuotedPrintableHeader($name, 'utf-8'); $partTypeString .= '; name="' . $name . '"'; $this->disposition .= '; filename="' . $name . '"'; } $this->type = $partTypeString; }
/** * Encode header fields * * Encodes header content according to RFC1522 if it contains non-printable * characters. * * @param string $value * @return string */ protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_QUOTEDPRINTABLE) { $quotedValue = Zend_Mime::encodeQuotedPrintable($value); $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue); return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_BASE64) { return '=?' . $this->_charset . '?B?' . Zend_Mime::encodeBase64($value) . '?='; } else { /** * @todo 7Bit and 8Bit is currently handled the same way. */ return $value; } }
/** * Return the boundary used in the MIME multipart message * * @return string The boundary used in the MIME multipart message */ public function getBoundary() { return $this->_mime->boundary(); }
/** * Get the Content of the current Mail Part in the given encoding. * * @return String */ public function getContent() { return Zend_Mime::encode($this->_content, $this->encoding); }
/** * get raw message as string * * @param Zend_Mail $mail * @param array $_additionalHeaders * @return string */ public function getRawMessage(Zend_Mail $mail = NULL, $_additionalHeaders = array()) { if ($mail !== NULL) { // this part is from Zend_Mail_Transport_Abstract::send() $this->_isMultipart = false; $this->_mail = $mail; $this->_parts = $mail->getParts(); $mime = $mail->getMime(); // Build body content $this->_buildBody(); // Determine number of parts and boundary $count = count($this->_parts); $boundary = null; if ($count < 1) { /** * @see Zend_Mail_Transport_Exception */ require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('Mail is empty'); } if ($count > 1) { // Multipart message; create new MIME object and boundary $mime = new Zend_Mime($this->_mail->getMimeBoundary()); $boundary = $mime->boundary(); } elseif ($this->_isMultipart) { // multipart/alternative -- grab boundary $boundary = $this->_parts[0]->boundary; } // Determine recipients, and prepare headers $this->recipients = implode(',', $mail->getRecipients()); $this->_prepareHeaders($this->_getHeaders($boundary)); // Create message body // This is done so that the same Zend_Mail object can be used in // multiple transports $message = new Zend_Mime_Message(); $message->setParts($this->_parts); $message->setMime($mime); $this->body = $message->generateMessage($this->EOL); } $mailAsString = $this->getHeaders($_additionalHeaders) . $this->EOL . $this->getBody(); // convert \n to \r\n $mailAsString = preg_replace("/(?<!\\r)\\n(?!\\r)/", "\r\n", $mailAsString); return $mailAsString; }
/** * Get the Content of the current Mime Part in the given encoding. * * @return String */ public function getContent($EOL = Zend_Mime::LINEEND) { if ($this->_isStream) { return stream_get_contents($this->getEncodedStream()); } else { return Zend_Mime::encode($this->_content, $this->encoding, $EOL); } }
public function testBase64() { $content = str_repeat("И™ѓњ)И™ѓњ)И™ѓ", 4); $encoded = Zend_Mime::encodeBase64($content); $this->assertEquals($content, base64_decode($encoded)); }
/** * Send a mail using this transport * * @param OpenPGP_Zend_Mail $mail * @access public * @return void * @throws Zend_Mail_Transport_Exception if mail is empty */ public function send(OpenPGP_Zend_Mail $mail) { $this->_isMultipart = false; $this->_mail = $mail; $this->_parts = $mail->getParts(); $mime = $mail->getMime(); // Build body content $this->_buildBody(); // Determine number of parts and boundary $count = count($this->_parts); $boundary = null; if ($count < 1) { throw new Zend_Mail_Transport_Exception('Empty mail cannot be sent'); } if ($count > 1) { // Multipart message; create new MIME object and boundary $mime = new Zend_Mime($this->_mail->getMimeBoundary()); $boundary = $mime->boundary(); } elseif ($this->_isMultipart) { // multipart/alternative -- grab boundary $boundary = $this->_parts[0]->boundary; } // Determine recipients, and prepare headers $this->recipients = implode(',', $mail->getRecipients()); $this->_prepareHeaders($this->_getHeaders($boundary)); // Create message body // This is done so that the same OpenPGP_Zend_Mail object can be used in // multiple transports $message = new Zend_Mime_Message(); $message->setParts($this->_parts); $message->setMime($mime); $this->body = $message->generateMessage($this->EOL); //////////////////////////////////////////////////////// // // // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION // // USING lib/openpgp/opepgplib.php // // // //////////////////////////////////////////////////////// // get from globals (set in tiki-setup.php) global $openpgplib; $pgpmime_msg = $openpgplib->prepareEncryptWithZendMail($this->header, $this->body, $mail->getRecipients()); $this->header = $pgpmime_msg[0]; // set pgp/mime headers from result array $this->body = $pgpmime_msg[1]; // set pgp/mime encrypted message body from result array //////////////////////////////////////////////////////// // // // ALPHAFIELDS 2012-11-03: ..END PGP/MIME ENCRYPTION // // // //////////////////////////////////////////////////////// // Send to transport! $this->_sendMail(); }
/** * @group ZF-1688 */ public function testLineLengthInQuotedPrintableHeaderEncoding() { $subject = "Alle meine Entchen schwimmen in dem See, schwimmen in dem See, Köpfchen in das Wasser, Schwänzchen in die Höh!"; $encoded = Zend_Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 100); foreach (explode(Zend_Mime::LINEEND, $encoded) as $line) { if (strlen($line) > 100) { $this->fail("Line '" . $line . "' is " . strlen($line) . " chars long, only 100 allowed."); } } $encoded = Zend_Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 40); foreach (explode(Zend_Mime::LINEEND, $encoded) as $line) { if (strlen($line) > 40) { $this->fail("Line '" . $line . "' is " . strlen($line) . " chars long, only 40 allowed."); } } }
/** * Get the Content of the current Mime Part in the given decoding. * * @return String */ public function getDecodedContent() { if ($this->_isStream) { $result = stream_get_contents($this->getDecodedStream()); } else { // Zend_Mime::decode not yet implemented $result = Zend_Mime::decode($this->_content, $this->encoding); } return $result; }
private function assertDateInSubject($period, $expectedDate) { $alerts = $this->getTriggeredAlerts(); Mail::setDefaultTransport(new \Zend_Mail_Transport_File()); $mail = new Mail(); $this->notifier->sendAlertsPerEmailToRecipient($alerts, $mail, '*****@*****.**', $period, 1); $expected = 'New alert for website Piwik test [' . $expectedDate . ']'; $expecteds = array($expected, \Zend_Mime::encodeQuotedPrintableHeader($expected, 'utf-8')); $isExpected = in_array($mail->getSubject(), $expecteds); $this->assertTrue($isExpected, $mail->getSubject() . " not found in " . var_export($expecteds, true)); }
/** * add attachments to mail * * @param Expressomail_mail $_mail * @param Expressomail_Model_Message $_message */ protected function _addAttachments(Expressomail_mail $_mail, Expressomail_Model_Message $_message) { if (!isset($_message->attachments) || empty($_message->attachments)) { return; } $size = 0; $tempFileBackend = Tinebase_TempFile::getInstance(); foreach ($_message->attachments as $attachment) { if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Adding attachment: ' . (is_object($attachment) ? print_r($attachment->toArray(), TRUE) : print_r($attachment, TRUE))); } if ($attachment['partId'] && $_message->original_id instanceof Expressomail_Model_Message) { $originlPart = $this->getMessagePart($_message->original_id, $attachment['partId']); switch ($originlPart->encoding) { case Zend_Mime::ENCODING_BASE64: $part = new Zend_Mime_Part(base64_decode(stream_get_contents($originlPart->getRawStream()))); $part->encoding = Zend_Mime::ENCODING_BASE64; break; case Zend_Mime::ENCODING_QUOTEDPRINTABLE: $part = new Zend_Mime_Part(quoted_printable_decode(stream_get_contents($originlPart->getRawStream()))); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; break; default: $part = new Zend_Mime_Part(stream_get_contents($originlPart->getRawStream())); $part->encoding = null; break; } $name = $attachment['name']; $type = $attachment['type']; } else { $tempFile = $attachment instanceof Tinebase_Model_TempFile ? $attachment : (array_key_exists('tempFile', $attachment) ? $tempFileBackend->get($attachment['tempFile']['id']) : NULL); if ($tempFile === NULL) { continue; } if (!$tempFile->path) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not find attachment.'); continue; } // get contents from uploaded file $stream = fopen($tempFile->path, 'r'); $part = new Zend_Mime_Part($stream); // RFC822 attachments are not encoded, set all others to ENCODING_BASE64 $part->encoding = $tempFile->type == Expressomail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822 ? null : Zend_Mime::ENCODING_BASE64; $name = $tempFile->name; $type = $tempFile->type; // try to detect the correct file type, on error fallback to the default application/octet-stream if ($tempFile->type == "undefined" || $tempFile->type == "unknown") { try { $finfo = finfo_open(FILEINFO_MIME_TYPE); $type = finfo_file($finfo, $tempFile->path); } catch (Exception $e) { $type = "application/octet-stream"; } try { finfo_close($finfo); } catch (Exception $e) { } } } $part->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; $name = Zend_Mime::encodeQuotedPrintableHeader(addslashes($name), 'utf-8'); $partTypeString = $type . '; name="' . $name . '"'; $part->type = $partTypeString; if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding attachment ' . $partTypeString); } $_mail->addAttachment($part); } }
/** * Generate MIME compliant message from the current configuration * * If both a text and HTML body are present, generates a * multipart/alternative Zend_Mime_Part containing the headers and contents * of each. Otherwise, uses whichever of the text or HTML parts present. * * The content part is then prepended to the list of Zend_Mime_Parts for * this message. * * @return void */ protected function _buildBody() { $text = $this->_mail->getBodyText(); $html = $this->_mail->getBodyHtml(); $htmlAttachments = $this->_mail->getHtmlRelatedAttachments(); $htmlAttachmentParts = $htmlAttachments->getParts(); $hasHtmlRelatedParts = count($htmlAttachmentParts); if ($text && $html || $html && $hasHtmlRelatedParts && count($this->_parts)) { // Generate unique boundary for multipart/alternative $mime = new Zend_Mime(null); $boundaryLine = $mime->boundaryLine($this->EOL); $boundaryEnd = $mime->mimeEnd($this->EOL); $html->disposition = false; if ($hasHtmlRelatedParts) { $message = new Zend_Mime_Message(); array_unshift($htmlAttachmentParts, $html); $message->setParts($htmlAttachmentParts); $htmlMime = $htmlAttachments->getMime(); $message->setMime($htmlMime); $html = new Zend_Mime_Part($message->generateMessage($this->EOL, false)); $html->boundary = $htmlMime->boundary(); $html->type = Zend_Mime::MULTIPART_RELATED; $html->encoding = null; } $body = $boundaryLine; if ($text) { $text->disposition = false; $body .= $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine; } $body .= $html->getHeaders($this->EOL) . $this->EOL . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd; $mp = new Zend_Mime_Part($body); $mp->type = Zend_Mime::MULTIPART_ALTERNATIVE; $mp->boundary = $mime->boundary(); $this->_isMultipart = true; // Ensure first part contains text alternatives array_unshift($this->_parts, $mp); // Get headers $this->_headers = $this->_mail->getHeaders(); return; } // If not multipart, then get the body if (false !== ($body = $this->_mail->getBodyHtml())) { array_unshift($this->_parts, $body); if ($hasHtmlRelatedParts) { $this->_mail->setType(Zend_Mime::MULTIPART_RELATED); foreach ($htmlAttachmentParts as $part) { $this->_parts[] = $part; } } } elseif (false !== ($body = $this->_mail->getBodyText())) { array_unshift($this->_parts, $body); } if (!$body) { /** * @see Zend_Mail_Transport_Exception */ require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('No body specified'); } // Get headers $this->_headers = $this->_mail->getHeaders(); $headers = $body->getHeadersArray($this->EOL); foreach ($headers as $header) { // Headers in Zend_Mime_Part are kept as arrays with two elements, a // key and a value $this->_headers[$header[0]] = array($header[1]); } }
/** * @param mixed $variableName * @param mixed $variableValue * @return string */ protected function encodeXdfnVariable($variableName, $variableValue) { if ($this->isReservedVariable($variableName)) { $variableName = '*' . $variableName; //reserved variables are prefixed } if ($variableName == '*parts') { $encoded = sprintf('%s=%s', $variableName, $variableValue); } else { $variableValue = addslashes($variableValue); $variableValue = Zend_Mime::encodeQuotedPrintable($variableValue, 4096); $variableValue = str_replace("\r", "", $variableValue); $variableValue = str_replace("\n", " ", $variableValue); $encoded = sprintf('%s="%s"', $variableName, $variableValue); } return $encoded; }
public function testBase64() { $content = str_repeat("\x88\xAA\xAF\xBF\x29\x88\xAA\xAF\xBF\x29\x88\xAA\xAF", 4); $encoded = Zend_Mime::encodeBase64($content); $this->assertEquals($content, base64_decode($encoded)); }
/** * Encode header fields * * Encodes header content according to RFC1522 if it contains non-printable * characters. * * @param string $value * @return string */ protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value) === false) { if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) { $value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND); } else { $value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND); } } return $value; }
$client = new Zend_Http_Client("http://de.wikipedia.org/w/index.php?title=PHP&printable=yes"); $string = $client->request()->getBody(); echo "===================================================================\n"; echo "RUNNING BENCHMARK\n"; echo "===================================================================\n"; echo "Starting encoding with imap_8bit() (" . LOOPS . " times)\n"; $startTime = microtime(true); for ($i = 0; $i < LOOPS; $i++) { imap_8bit($string); } $durationImap_8bit = microtime(true) - $startTime; echo "Duration: " . round($durationImap_8bit, 4) . " seconds\n\n"; echo "Starting encoding with Zend_Mime::encodeQuotedPrintable() (" . LOOPS . " times)\n"; $startTime = microtime(true); for ($i = 0; $i < LOOPS; $i++) { Zend_Mime::encodeQuotedPrintable($string, Zend_Mime::LINELENGTH, Zend_Mime::LINEEND); } $durationZendMime = microtime(true) - $startTime; echo "Duration: " . round($durationZendMime, 4) . " seconds\n\n"; echo "Starting encoding with quoted_printable_encode() (" . LOOPS . " times)\n"; $startTime = microtime(true); for ($i = 0; $i < LOOPS; $i++) { quoted_printable_encode($string); } $durationQPE = microtime(true) - $startTime; echo "Duration: " . round($durationQPE, 4) . " seconds\n\n"; echo "===================================================================\n"; echo "SUMMARY\n"; echo "===================================================================\n"; echo "imap_8bit() is " . round($durationZendMime - $durationImap_8bit, 4) . " seconds faster than Zend_Mime!\n"; echo "It is " . round($durationZendMime / $durationImap_8bit, 2) . " times faster\n\n";
/** * Send a mail using this transport * * @param Zend_Mail $mail * @access public * @return void * @throws Zend_Mail_Transport_Exception if mail is empty */ public function send(Zend_Mail $mail) { $this->_isMultipart = false; $this->_mail = $mail; $this->_parts = $mail->getParts(); $mime = $mail->getMime(); // Build body content $this->_buildBody(); // Determine number of parts and boundary $count = count($this->_parts); $boundary = null; if ($count < 1) { /** * @see Zend_Mail_Transport_Exception */ // require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('Empty mail cannot be sent'); } if ($count > 1) { // Multipart message; create new MIME object and boundary $mime = new Zend_Mime($this->_mail->getMimeBoundary()); $boundary = $mime->boundary(); } elseif ($this->_isMultipart) { // multipart/alternative -- grab boundary $boundary = $this->_parts[0]->boundary; } // Determine recipients, and prepare headers $this->recipients = implode(',', $mail->getRecipients()); $this->_prepareHeaders($this->_getHeaders($boundary)); // Create message body // This is done so that the same Zend_Mail object can be used in // multiple transports $message = new Zend_Mime_Message(); $message->setParts($this->_parts); $message->setMime($mime); $this->body = $message->generateMessage($this->EOL); // Send to transport! $this->_sendMail(); }
/** * Assertion that checks if a given mailing header string is RFC conform. * * @param string $header * @return void */ protected function assertMailHeaderConformsToRfc($header) { $this->numAssertions++; $parts = explode(Zend_Mime::LINEEND, $header); if (count($parts) > 0) { for ($i = 0; $i < count($parts); $i++) { if (preg_match('/(=?[a-z0-9-_]+\\?[q|b]{1}\\?)/i', $parts[$i], $matches)) { $dce = sprintf("=?%s", $matches[0]); // Check that Delimiter, Charset, Encoding are at the front of the string if (substr(trim($parts[$i]), 0, strlen($dce)) != $dce) { $this->fail(sprintf("Header-Part '%s' in line '%d' has missing or malformated delimiter, charset, encoding information.", $parts[$i], $i + 1)); } // check that the encoded word is not too long.); // this is only some kind of suggestion by the standard, in PHP its hard to hold it, so we do not enforce it here. /*if(strlen($parts[$i]) > 75) { $this->fail(sprintf( "Each encoded-word is only allowed to be 75 chars long, but line %d is %s chars long: %s", $i+1, strlen($parts[$i]), $parts[$i] )); }*/ // Check that the end-delmiter ?= is correctly placed if (substr(trim($parts[$i]), -2, 2) != "?=") { $this->fail(sprintf("Lines with an encoded-word have to end in ?=, but line %d does not: %s", $i + 1, substr(trim($parts[$i]), -2, 2))); } // Check that only one encoded-word can be found per line. if (substr_count($parts[$i], "=?") != 1) { $this->fail(sprintf("Only one encoded-word is allowed per line in the header. It seems line %d contains more: %s", $i + 1, $parts[$i])); } // Check that the encoded-text only contains US-ASCII chars, and no space $encodedText = substr(trim($parts[$i]), strlen($dce), -2); if (preg_match('/([\\s]+)/', $encodedText)) { $this->fail(sprintf("No whitespace characters allowed in encoded-text of line %d: %s", $i + 1, $parts[$i])); } for ($i = 0; $i < strlen($encodedText); $i++) { if (ord($encodedText[$i]) > 127) { $this->fail(sprintf("No non US-ASCII characters allowed, but line %d has them: %s", $i + 1, $parts[$i])); } } } else { if (Zend_Mime::isPrintable($parts[$i]) == false) { $this->fail(sprintf("Encoded-word in line %d contains non printable characters.", $i + 1)); } } } } }