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


PHP Zend_Mime_Message::createFromMessage方法代码示例

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


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

示例1: testDecodeMimeMessage

    /**
     * check if decoding a string into a Zend_Mime_Message object works
     *
     */
    public function testDecodeMimeMessage()
    {
        $text = <<<EOD
This is a message in Mime Format.  If you see this, your mail reader does not support this format.

--=_af4357ef34b786aae1491b0a2d14399f
Content-Type: application/octet-stream
Content-Transfer-Encoding: 8bit

This is a test
--=_af4357ef34b786aae1491b0a2d14399f
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-ID: <12>

This is another test
--=_af4357ef34b786aae1491b0a2d14399f--
EOD;
        $res = Zend_Mime_Message::createFromMessage($text, '=_af4357ef34b786aae1491b0a2d14399f');
        $parts = $res->getParts();
        $this->assertEquals(2, count($parts));
        $part1 = $parts[0];
        $this->assertEquals('application/octet-stream', $part1->type);
        $this->assertEquals('8bit', $part1->encoding);
        $part2 = $parts[1];
        $this->assertEquals('image/gif', $part2->type);
        $this->assertEquals('base64', $part2->encoding);
        $this->assertEquals('12', $part2->id);
    }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:33,代码来源:MessageTest.php

示例2: _multipartToFiles

 protected function _multipartToFiles()
 {
     $files = array();
     list($contentType, $boundary) = explode(';', $_SERVER['CONTENT_TYPE']);
     if ($contentType == 'multipart/mixed') {
         list(, $boundary) = explode('=', trim($boundary));
     } else {
         throw new Zend_File_Transfer_Exception('This is not a multipart/mixed call');
     }
     $data = file_get_contents('php://input');
     $message = Zend_Mime_Message::createFromMessage($data, $boundary);
     foreach ($message->getParts() as $part) {
         if (!empty($part->disposition)) {
             $part->disposition = preg_replace('/;/', '&', $part->disposition);
             parse_str($part->disposition, $disposition);
             foreach ($disposition as $key => $value) {
                 $disposition[$key] = preg_replace('/"/', '', $value);
             }
         }
         if (!empty($disposition['name'])) {
             $name = $disposition['name'];
         }
         if (!empty($disposition['filename'])) {
             $filename = $disposition['filename'];
         }
         if (!empty($part->filename)) {
             $filename = $part->filename;
         }
         if (!empty($name) && !empty($filename)) {
             $files[$name]['name'] = $filename;
             $files[$name]['type'] = $part->type;
             $files[$name]['error'] = 0;
             file_put_contents(sys_get_temp_dir() . '/' . $filename, $part->getContent());
             $files[$name]['tmp_name'] = sys_get_temp_dir() . '/' . $filename;
             $files[$name]['size'] = filesize(sys_get_temp_dir() . '/' . $filename);
         }
     }
     return $files;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:39,代码来源:HttpMultipartMixed.php

示例3: _processSignedMessage

 protected function _processSignedMessage($rawMessage)
 {
     $headers = '';
     $matches = array();
     preg_match('/.*boundary="(.*)"/', $headers['content-type'], $matches);
     list(, $boundary) = $matches;
     $signedMail = Zend_Mime_Message::createFromMessage($rawMessage, $boundary);
     return $signedMail;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:9,代码来源:Send.php

示例4: renderMail

 function renderMail($obj, $controller, $field, Am_Grid_Field_Expandable $fieldObj)
 {
     $_body = $obj->body;
     $_headers = unserialize($obj->headers);
     $atRendered = null;
     $val = '';
     $headers = array();
     foreach ($_headers as $k => $v) {
         $headers[$k] = $v[0];
     }
     if (isset($headers['Content-Transfer-Encoding']) && $headers['Content-Transfer-Encoding'] == 'quoted-printable') {
         $body = quoted_printable_decode($_body);
         if (strpos($headers['Subject'], '=?') === 0) {
             $headers['Subject'] = mb_decode_mimeheader($headers['Subject']);
         }
     } else {
         $body = base64_decode($_body);
     }
     if ($body) {
         $body = nl2br($body);
     }
     foreach ($headers as $headerName => $headerVal) {
         $val .= '<b>' . $headerName . '</b> : <i>' . Am_Controller::escape($headerVal) . '</i><br />';
     }
     if (isset($headers['Content-Type']) && strstr($headers['Content-Type'], 'multipart/mixed')) {
         preg_match('/boundary="(.*)"/', $headers['Content-Type'], $matches);
         $boundary = $matches[1];
         $message = @Zend_Mime_Message::createFromMessage($body, $boundary);
         $parts = $message->getParts();
         $part = @$parts[0];
         if ($part) {
             $body = $part->getContent();
             if ($part->encoding == 'quoted-printable') {
                 $body = quoted_printable_decode($body);
             } else {
                 $body = base64_decode($body);
             }
         }
         $attachments = array_slice($parts, 1);
         $atRendered = '';
         foreach ($attachments as $at) {
             preg_match('/filename="(.*)"/', $at->disposition, $matches);
             $filename = @$matches[1];
             $atRendered .= sprintf("&mdash %s (%s)", $filename, $at->type) . '<br />';
         }
     }
     $val .= '<br />' . $body . ($atRendered ? '<br /><strong>Attachments:</strong><br />' . $atRendered : '');
     return $val;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:49,代码来源:AdminLogsController.php


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