当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Mime_Decode::splitMessage方法代码示例

本文整理汇总了PHP中Zend_Mime_Decode::splitMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mime_Decode::splitMessage方法的具体用法?PHP Zend_Mime_Decode::splitMessage怎么用?PHP Zend_Mime_Decode::splitMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Mime_Decode的用法示例。


在下文中一共展示了Zend_Mime_Decode::splitMessage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHtmlBodyAndAttachmentData

 /**
  * recover html body and atachment data from rfc822 mime
  *
  * @param string $mime
  * @return array
  */
 public function getHtmlBodyAndAttachmentData($mime, $onlyInline = FALSE)
 {
     //$filepath = '../tests/tine20/Expressomail/Frontend/files/mime/';
     //$filename = microtime();
     //file_put_contents($filepath.$filename.'.eml', $mime);
     preg_match('/.*boundary="(.*)"/', $mime, $matches);
     if (count($matches) === 0) {
         Zend_Mime_Decode::splitMessage($mime, $headers, $body);
         $body = base64_decode($body);
         if (strpos($headers['content-type'], 'text/plain') !== FALSE) {
             $body = $this->convertPlainTextToHtml($body);
         }
         $result = array('body' => $body);
         //file_put_contents($filename.'.json', json_encode($result));
         return $result;
     }
     $struct = Zend_Mime_Decode::splitMessageStruct($mime, $matches[1]);
     $result = array();
     $result['attachmentData'] = array();
     $multipartContent = $this->getMultipartPart($struct, 'multipart');
     if ($multipartContent) {
         preg_match('/.*boundary="(.*)"/', $multipartContent['header']['content-type'], $matches);
         $bodyBoundary = $matches[1];
         $bodyStruct = Zend_Mime_Decode::splitMessageStruct($multipartContent['body'], $bodyBoundary);
         $bodyContent = $this->getMultipartPart($bodyStruct, 'text/html');
         if ($bodyContent) {
             $bodyHtml = $this->extractBodyTagContent($bodyContent['body']);
             if (strpos($bodyContent['header']['content-transfer-encoding'], 'base64') !== FALSE) {
                 $bodyHtml = base64_decode($bodyHtml);
             }
         } else {
             $bodyHtml = '';
         }
         $result['attachmentData'] = $this->getAttachmentParts($bodyStruct, $onlyInline);
     } else {
         $bodyContent = $this->getMultipartPart($struct, 'text/html');
         if ($bodyContent) {
             if (strpos($bodyContent['header']['content-transfer-encoding'], 'base64') !== FALSE) {
                 $bodyHtml = base64_decode($bodyContent['body']);
             } else {
                 $bodyHtml = $this->extractBodyTagContent($bodyContent['body']);
             }
         } else {
             $bodyContent = $this->getMultipartPart($struct, 'text');
             $bodyHtml = $bodyContent['body'];
             if (strpos($bodyContent['header']['content-transfer-encoding'], 'base64') !== FALSE) {
                 $bodyHtml = base64_decode($bodyHtml);
             }
             if (strpos($bodyContent['header']['content-type'], 'text/plain') !== FALSE) {
                 $bodyHtml = $this->convertPlainTextToHtml($bodyHtml);
             }
         }
     }
     $result['body'] = quoted_printable_decode($bodyHtml);
     $result['attachmentData'] = array_merge($result['attachmentData'], $this->getAttachmentParts($struct, $onlyInline));
     //$filepath = '../tests/tine20/Expressomail/Frontend/files/result/';
     //file_put_contents($filepath.$filename.'.json', json_encode($result));
     return $result;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:65,代码来源:ActiveSync.php

示例2: __construct

 /**
  * Public constructor
  *
  * @param string $rawMessage  full message with or without headers
  * @param array  $headers     optional headers already seperated from body
  */
 public function __construct($rawMessage, $headers = null)
 {
     if ($headers) {
         if (is_array($headers)) {
             $this->_headers = $headers;
             $this->_content = $rawMessage;
         } else {
             Zend_Mime_Decode::splitMessage($headers, $this->_headers, $null);
             $this->_content = $rawMessage;
         }
     } else {
         Zend_Mime_Decode::splitMessage($rawMessage, $this->_headers, $this->_content);
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:Message.php

示例3: __construct

 /**
  * Public constructor
  *
  * This handler supports the following params:
  * - file     filename or open file handler with message content (required)
  * - startPos start position of message or part in file (default: current position)
  * - endPos   end position of message or part in file (default: end of file)
  *
  * @param   array $params  full message with or without headers
  * @throws  Zend_Mail_Exception
  */
 public function __construct(array $params)
 {
     if (empty($params['file'])) {
         /**
          * @see Zend_Mail_Exception
          */
         // require_once 'Zend/Mail/Exception.php';
         throw new Zend_Mail_Exception('no file given in params');
     }
     if (!is_resource($params['file'])) {
         $this->_fh = fopen($params['file'], 'r');
     } else {
         $this->_fh = $params['file'];
     }
     if (!$this->_fh) {
         /**
          * @see Zend_Mail_Exception
          */
         // require_once 'Zend/Mail/Exception.php';
         throw new Zend_Mail_Exception('could not open file');
     }
     if (isset($params['startPos'])) {
         fseek($this->_fh, $params['startPos']);
     }
     $header = '';
     $endPos = isset($params['endPos']) ? $params['endPos'] : null;
     while (($endPos === null || ftell($this->_fh) < $endPos) && trim($line = fgets($this->_fh))) {
         $header .= $line;
     }
     Zend_Mime_Decode::splitMessage($header, $this->_headers, $null);
     $this->_contentPos[0] = ftell($this->_fh);
     if ($endPos !== null) {
         $this->_contentPos[1] = $endPos;
     } else {
         fseek($this->_fh, 0, SEEK_END);
         $this->_contentPos[1] = ftell($this->_fh);
     }
     if (!$this->isMultipart()) {
         return;
     }
     $boundary = $this->getHeaderField('content-type', 'boundary');
     if (!$boundary) {
         /**
          * @see Zend_Mail_Exception
          */
         // require_once 'Zend/Mail/Exception.php';
         throw new Zend_Mail_Exception('no boundary found in content type to split message');
     }
     $part = array();
     $pos = $this->_contentPos[0];
     fseek($this->_fh, $pos);
     while (!feof($this->_fh) && ($endPos === null || $pos < $endPos)) {
         $line = fgets($this->_fh);
         if ($line === false) {
             if (feof($this->_fh)) {
                 break;
             }
             /**
              * @see Zend_Mail_Exception
              */
             // require_once 'Zend/Mail/Exception.php';
             throw new Zend_Mail_Exception('error reading file');
         }
         $lastPos = $pos;
         $pos = ftell($this->_fh);
         $line = trim($line);
         if ($line == '--' . $boundary) {
             if ($part) {
                 // not first part
                 $part[1] = $lastPos;
                 $this->_partPos[] = $part;
             }
             $part = array($pos);
         } else {
             if ($line == '--' . $boundary . '--') {
                 $part[1] = $lastPos;
                 $this->_partPos[] = $part;
                 break;
             }
         }
     }
     $this->_countParts = count($this->_partPos);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:94,代码来源:File.php

示例4: getSummary

 /**
  * get messages summary
  *
  * @param int $from
  * @param int|null $to
  * @return array with $this->_messageClass (Felamimail_Message)
  */
 public function getSummary($from, $to = null, $_useUid = null)
 {
     $useUid = $_useUid === null ? $this->_useUid : (bool) $_useUid;
     $summary = $this->_protocol->fetch(array('UID', 'FLAGS', 'RFC822.HEADER', 'INTERNALDATE', 'RFC822.SIZE', 'BODYSTRUCTURE'), $from, $to, $useUid);
     // sometimes ctype_digit($from) is false even if we got a single message, maybe mailserver dependend
     $singleMessage = $to === null && ctype_digit($from) || isset($summary['UID']);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' to: ' . print_r($to, true) . ' from: ' . print_r($from, true) . ' ctype_digit(from): ' . (int) ctype_digit($from));
     }
     // fetch returns a different structure when fetching one or multiple messages
     if ($singleMessage) {
         $summary = array($from => $summary);
     }
     $messages = array();
     foreach ($summary as $id => $data) {
         if (!isset($data['RFC822.HEADER'])) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Message data invalid: ' . print_r($data, true) . print_r($summary, true));
             }
             continue;
         }
         $header = $this->_fixHeader($data['RFC822.HEADER'], $id, $spaces);
         Zend_Mime_Decode::splitMessage($header, $header, $null);
         $structure = $this->parseStructure($data['BODYSTRUCTURE']);
         $flags = array();
         foreach ($data['FLAGS'] as $flag) {
             $flags[] = isset(self::$_knownFlags[$flag]) ? self::$_knownFlags[$flag] : $flag;
         }
         if ($this->_useUid === true) {
             $key = $data['UID'];
         } else {
             $key = $id;
         }
         $messages[$key] = array('header' => $header, 'flags' => $flags, 'received' => $data['INTERNALDATE'], 'size' => $data['RFC822.SIZE'], 'structure' => $structure, 'uid' => $data['UID']);
     }
     if ($singleMessage) {
         return $messages[$from];
     } else {
         // multiple messages requested
         return $messages;
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:49,代码来源:Imap.php

示例5: getHeaders

 /**
  * Get all headers
  *
  * The returned headers are as saved internally. All names are lowercased. The value is a string or an array
  * if a header with the same name occurs more than once.
  *
  * @return array headers as array(name => value)
  */
 public function getHeaders()
 {
     if ($this->_headers === null) {
         if (!$this->_mail) {
             $this->_headers = array();
         } else {
             $part = $this->_mail->getRawHeader($this->_messageNum);
             Zend_Mime_Decode::splitMessage($part, $this->_headers, $null);
         }
     }
     return $this->_headers;
 }
开发者ID:bartolomeu,项目名称:estoque_gusella,代码行数:20,代码来源:Part.php

示例6: getRawContent

 public function getRawContent($id, $part = null)
 {
     if ($part !== null) {
         // TODO: implement
         throw new Zend_Mail_Storage_Exception('not implemented');
     }
     $content = $this->_protocol->retrieve($id);
     // TODO: find a way to avoid decoding the headers
     Zend_Mime_Decode::splitMessage($content, $null, $body);
     return $body;
 }
开发者ID:ismaelmelus,项目名称:home,代码行数:11,代码来源:Pop3.php

示例7: getRawContent

 public function getRawContent($id, $part = null)
 {
     if ($part !== null) {
         // TODO: implement
         /**
          * @see Zend_Mail_Storage_Exception
          */
         require_once PHP_LIBRARY_PATH . 'Zend/Mail/Storage/Exception.php';
         throw new Zend_Mail_Storage_Exception('not implemented');
     }
     $content = $this->_protocol->retrieve($id);
     // TODO: find a way to avoid decoding the headers
     Zend_Mime_Decode::splitMessage($content, $null, $body);
     return $body;
 }
开发者ID:netixx,项目名称:Stock,代码行数:15,代码来源:Pop3.php

示例8: getMessageHeaders

 /**
  * get message headers
  *
  * @param string|Expressomail_Model_Message $_messageId
  * @param boolean $_readOnly
  * @return array
  * @throws Expressomail_Exception_IMAPMessageNotFound
  */
 public function getMessageHeaders($_messageId, $_partId = null, $_readOnly = false)
 {
     if (!$_messageId instanceof Expressomail_Model_Message) {
         $message = $this->_backend->get($_messageId);
     } else {
         $message = $_messageId;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Fetching headers for message uid ' . $message->messageuid . ' (part:' . $_partId . ')');
     }
     try {
         $imapBackend = $this->_getBackendAndSelectFolder($message->folder_id);
     } catch (Zend_Mail_Storage_Exception $zmse) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $zmse->getMessage());
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $zmse->getTraceAsString());
         }
         throw new Expressomail_Exception_IMAPMessageNotFound('Folder not found');
     }
     if ($imapBackend === null) {
         throw new Expressomail_Exception('Failed to get imap backend');
     }
     $section = $_partId === null ? 'HEADER' : $_partId . '.HEADER';
     try {
         $rawHeaders = $imapBackend->getRawContent($message->messageuid, $section, $_readOnly);
         if (strtolower(mb_detect_encoding($rawHeaders)) == 'utf-8') {
             $rawHeaders = utf8_decode(imap_utf8($rawHeaders));
         }
     } catch (Expressomail_Exception_IMAPMessageNotFound $feimnf) {
         $this->_backend->delete($message->getId());
         throw $feimnf;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Fetched Headers: ' . $rawHeaders);
     }
     Zend_Mime_Decode::splitMessage($rawHeaders, $headers, $null);
     return $headers;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:48,代码来源:Message.php

示例9: testSplitMessage

 public function testSplitMessage()
 {
     $header = 'Test: test';
     $body = 'body';
     $newlines = array("\r\n", "\n\r", "\n", "\r");
     foreach ($newlines as $contentEOL) {
         foreach ($newlines as $decodeEOL) {
             $content = $header . $contentEOL . $contentEOL . $body;
             $decoded = Zend_Mime_Decode::splitMessage($content, $decoded_header, $decoded_body, $decodeEOL);
             $this->assertEquals(array('test' => 'test'), $decoded_header);
             $this->assertEquals($body, $decoded_body);
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:MessageTest.php

示例10: getMessageHeaders

 /**
  * get message headers
  * 
  * @param string|Felamimail_Model_Message $_messageId
  * @param boolean $_readOnly
  * @return array
  * @throws Felamimail_Exception_IMAPMessageNotFound
  */
 public function getMessageHeaders($_messageId, $_partId = null, $_readOnly = false)
 {
     if (!$_messageId instanceof Felamimail_Model_Message) {
         $message = $this->_backend->get($_messageId);
     } else {
         $message = $_messageId;
     }
     $cache = Tinebase_Core::get('cache');
     $cacheId = 'getMessageHeaders' . $message->getId() . str_replace('.', '', $_partId);
     if ($cache->test($cacheId)) {
         return $cache->load($cacheId);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Fetching headers for message uid ' . $message->messageuid . ' (part:' . $_partId . ')');
     }
     try {
         $imapBackend = $this->_getBackendAndSelectFolder($message->folder_id);
     } catch (Zend_Mail_Storage_Exception $zmse) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $zmse->getMessage());
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $zmse->getTraceAsString());
         }
         throw new Felamimail_Exception_IMAPMessageNotFound('Folder not found');
     }
     if ($imapBackend === null) {
         throw new Felamimail_Exception('Failed to get imap backend');
     }
     $section = $_partId === null ? 'HEADER' : $_partId . '.HEADER';
     try {
         $rawHeaders = $imapBackend->getRawContent($message->messageuid, $section, $_readOnly);
     } catch (Felamimail_Exception_IMAPMessageNotFound $feimnf) {
         $this->_backend->delete($message->getId());
         throw $feimnf;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Fetched Headers: ' . $rawHeaders);
     }
     $headers = array();
     $body = null;
     Zend_Mime_Decode::splitMessage($rawHeaders, $headers, $body);
     $cache->save($headers, $cacheId, array('getMessageHeaders'), 86400);
     return $headers;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:53,代码来源:Message.php

示例11: _processDeliveryStatus

 protected function _processDeliveryStatus($deliveryStatus, $textContent, $originalContent)
 {
     $statusContent = preg_replace('#\\r?\\n\\r?\\n#', "\n", trim($deliveryStatus));
     Zend_Mime_Decode::splitMessage($statusContent, $statusFields, $null);
     foreach ($statusFields as &$value) {
         if (is_array($value)) {
             $value = reset($value);
         }
     }
     if (!empty($statusFields['action'])) {
         $this->_action = strtolower($statusFields['action']);
         if ($this->_action == 'failed') {
             $this->_messageType = 'bounce';
         } else {
             if ($this->_action == 'delayed') {
                 $this->_messageType = 'delay';
             }
         }
     }
     if (!empty($statusFields['status']) && preg_match('/(\\d\\.\\d\\.\\d)/', $statusFields['status'], $match)) {
         $this->_statusCode = $match[1];
     }
     if (!empty($statusFields['diagnostic-code'])) {
         $this->_diagnosticInfo = preg_replace('#^.+;\\s*#U', '', $statusFields['diagnostic-code']);
         if (!$this->_statusCode || $this->isStatusCodeAmbiguous($this->_statusCode)) {
             if (preg_match('/(\\D|^)(\\d\\.\\d\\.\\d)(\\D|$)/', $this->_diagnosticInfo, $match)) {
                 $this->_statusCode = $match[2];
             }
         }
     }
     if ($this->_action == 'failed' && $this->_diagnosticInfo && $this->_isMailboxInvalid($this->_diagnosticInfo)) {
         $this->_statusCode = '5.1.1';
     } else {
         if ($this->isStatusCodeAmbiguous($this->_statusCode) && $this->_diagnosticInfo && $this->_isMailboxQuotaExceeded($this->_diagnosticInfo)) {
             $this->_statusCode = '5.2.2';
         } else {
             if ($this->_statusCode == '4.7.0' && $this->_isChallengeResponse($textContent) || $this->isStatusCodeAmbiguous($this->_statusCode) && $this->_diagnosticInfo && $this->_isChallengeResponse($this->_diagnosticInfo)) {
                 $this->_messageType = 'challenge';
                 $this->_statusCode = null;
                 $this->_action = null;
             }
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:44,代码来源:BounceParser.php

示例12: getSummary

 /**
  * get messages summary
  *
  * @param int $from
  * @param int|null $to
  * @return array with $this->_messageClass (Felamimail_Message)
  */
 public function getSummary($from, $to = null, $_useUid = null, $_folderId = NULL)
 {
     $useUid = $_useUid === null ? $this->_useUid : (bool) $_useUid;
     $summary = $this->_protocol->fetch(array('UID', 'FLAGS', 'RFC822.HEADER', 'INTERNALDATE', 'RFC822.SIZE', 'BODYSTRUCTURE'), $from, $to, $useUid);
     // fetch returns a different structure when fetching one or multiple messages
     if ($to === null && ctype_digit("{$from}")) {
         $summary = array($from => $summary);
     }
     $messages = array();
     foreach ($summary as $id => $data) {
         $header = $this->_fixHeader($data['RFC822.HEADER'], $id, $spaces);
         Zend_Mime_Decode::splitMessage($header, $header, $null);
         $structure = $this->parseStructure($data['BODYSTRUCTURE']);
         $flags = array();
         foreach ($data['FLAGS'] as $flag) {
             $flags[] = isset(self::$_knownFlags[$flag]) ? self::$_knownFlags[$flag] : $flag;
         }
         if ($this->_useUid === true) {
             $key = $data['UID'];
         } else {
             $key = $id;
         }
         $messages[$key] = array('header' => $header, 'flags' => $flags, 'received' => $data['INTERNALDATE'], 'size' => $data['RFC822.SIZE'], 'structure' => $structure, 'uid' => $data['UID']);
         if (!empty($_folderId)) {
             $messages[$key]['folder_id'] = $_folderId;
         }
     }
     if ($to === null && ctype_digit("{$from}")) {
         // only one message requested
         return $messages[$from];
     } else {
         // multiple messages requested
         return $messages;
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:42,代码来源:Imap.php

示例13: decodeRFC822

 /**
  * Parse an RFC-822 message
  *
  * this format is quite old and not used anymore but some old
  * devices may still send it
  *
  * @param string $message
  * @return array
  */
 public static function decodeRFC822(&$message)
 {
     try {
         Zend_Mime_Decode::splitMessage(ltrim($message), $headers, $content);
         $contentType = isset($headers['content-type']) ? $headers['content-type'] : '';
         if ($contentType) {
             $contentType = Zend_Mime_Decode::splitContentType($contentType);
         }
         if (isset($contentType['boundary'])) {
             $mimeParts = self::splitMessageStruct($content, $contentType['boundary']);
         } else {
             $mimeParts = array();
         }
         $message = array('headers' => $headers, 'content' => $content, 'mime_parts' => $mimeParts, 'content_type' => $contentType);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:jsiefer,项目名称:emarketing,代码行数:28,代码来源:Decode.php


注:本文中的Zend_Mime_Decode::splitMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。