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


PHP Zend_Mime_Message::addPart方法代码示例

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


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

示例1: testGenerate

 public function testGenerate()
 {
     $msg = new Zend_Mime_Message();
     // No Parts
     $p1 = new Zend_Mime_Part('This is a test');
     $p2 = new Zend_Mime_Part('This is another test');
     $msg->addPart($p1);
     $msg->addPart($p2);
     $res = $msg->generateMessage();
     $mime = $msg->getMime();
     $boundary = $mime->boundary();
     $p1 = strpos($res, $boundary);
     // $boundary must appear once for every mime part
     $this->assertTrue($p1 !== false);
     if ($p1) {
         $p2 = strpos($res, $boundary, $p1 + strlen($boundary));
         $this->assertTrue($p2 !== false);
     }
     // check if the two test messages appear:
     $this->assertTrue(strpos($res, 'This is a test') !== false);
     $this->assertTrue(strpos($res, 'This is another test') !== false);
     // ... more in ZMailTest
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:23,代码来源:MessageTest.php

示例2: encode

 /**
  * Return the MIME multipart representation of this MediaEntry.
  *
  * @return string The MIME multipart representation of this MediaEntry
  */
 public function encode()
 {
     $xmlData = $this->saveXML();
     if ($this->getMediaSource() === null) {
         // No attachment, just send XML for entry
         return $xmlData;
     } else {
         $mimeMessage = new Zend_Mime_Message();
         $mimeMessage->setMime($this->_mime);
         $xmlPart = new Zend_Mime_Part($xmlData);
         $xmlPart->type = 'application/atom+xml';
         $xmlPart->encoding = null;
         $mimeMessage->addPart($xmlPart);
         $binaryPart = new Zend_Mime_Part($this->getMediaSource()->encode());
         $binaryPart->type = $this->getMediaSource()->getContentType();
         $binaryPart->encoding = null;
         $mimeMessage->addPart($binaryPart);
         return $mimeMessage->generateMessage();
     }
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:25,代码来源:MediaEntry.php

示例3: createFromMessage

 /**
  * Decodes a MIME encoded string and returns a Zend_Mime_Message object with
  * all the MIME parts set according to the given string
  *
  * @param string $message
  * @param string $boundary
  * @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
  * @return Zend_Mime_Message
  */
 public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND)
 {
     $partsStr = self::_disassembleMime($message, $boundary);
     if (count($partsStr) <= 0) {
         return null;
     }
     $res = new Zend_Mime_Message();
     foreach ($partsStr as $part) {
         // separate header and body
         $header = true;
         // expecting header lines first
         $headersfound = array();
         $body = '';
         $lastheader = '';
         $lines = explode("\n", $part);
         // read line by line
         foreach ($lines as $line) {
             $line = trim($line);
             if ($header) {
                 if ($line == '') {
                     $header = false;
                 } elseif (strpos($line, ':')) {
                     list($key, $value) = explode(':', $line, 2);
                     $headersfound[trim($key)] = trim($value);
                     $lastheader = trim($key);
                 } else {
                     if ($lastheader != '') {
                         $headersfound[$lastheader] .= ' ' . trim($line);
                     } else {
                         // headers do not start with an ordinary header line?
                         // then assume no headers at all
                         $header = false;
                     }
                 }
             } else {
                 $body .= $line . $EOL;
             }
         }
         // now we build a new MimePart for the current Message Part:
         $newPart = new Zend_Mime_Part($body);
         foreach ($headersfound as $key => $value) {
             /**
              * @todo check for characterset and filename
              */
             switch ($key) {
                 case 'Content-Type':
                     $newPart->type = $value;
                     break;
                 case 'Content-Transfer-Encoding':
                     $newPart->encoding = $value;
                     break;
                 case 'Content-ID':
                     $newPart->id = trim($value, '<>');
                     break;
                 case 'Content-Disposition':
                     $newPart->disposition = $value;
                     break;
                 case 'Content-Description':
                     $newPart->description = $value;
                     break;
                 default:
                     throw new Zend_Exception('Unknown header ignored for MimePart:' . $key);
             }
         }
         $res->addPart($newPart);
     }
     return $res;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:77,代码来源:Message.php

示例4: createFromMessage

 /**
  * Decodes a MIME encoded string and returns a Zend_Mime_Message object with
  * all the MIME parts set according to the given string
  *
  * @param string $message
  * @param string $boundary
  * @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
  * @return Zend_Mime_Message
  */
 public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND)
 {
     require_once 'Zend/Mime/Decode.php';
     $parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary, $EOL);
     $res = new Zend_Mime_Message();
     foreach ($parts as $part) {
         // now we build a new MimePart for the current Message Part:
         $newPart = new Zend_Mime_Part($part);
         foreach ($part['header'] as $key => $value) {
             /**
              * @todo check for characterset and filename
              */
             // list($key, $value) = $header;
             switch ($key) {
                 case 'content-type':
                     $newPart->type = $value;
                     break;
                 case 'content-transfer-encoding':
                     $newPart->encoding = $value;
                     break;
                 case 'content-id':
                     $newPart->id = trim($value, '<>');
                     break;
                 case 'Content-Disposition':
                     $newPart->disposition = $value;
                     break;
                 case 'content-description':
                     $newPart->description = $value;
                     break;
                 default:
                     throw new Zend_Exception('Unknown header ignored for MimePart:' . $key);
             }
         }
         $res->addPart($newPart);
     }
     return $res;
 }
开发者ID:janssit,项目名称:www.ondernemenddiest.be,代码行数:46,代码来源:Message.php

示例5: testCSVFileUpload

 public function testCSVFileUpload()
 {
     $this->markTestIncomplete('The implementation is not yet finished and needs adaptation to new unit tests system.');
     try {
         $this->_httpClient->setUri($this->_baseUri . '/files');
         $this->_httpClient->setMethod(Zend_Http_Client::POST);
         $msg = new Zend_Mime_Message();
         $jsonPart = new Zend_Mime_Part('{}');
         $jsonPart->type = 'application/json';
         $jsonPart->filename = microtime(true) . '.json';
         $jsonPart->disposition = 'attachment';
         $msg->addPart($jsonPart);
         $xmlPart = new Zend_Mime_Part($this->_icc . ',GEM17223,2,SIM_Model,APN1,10.1.2.1,1,TM SPAIN');
         $xmlPart->type = 'text/plain';
         $xmlPart->filename = microtime(true) . '.csv';
         $xmlPart->disposition = 'attachment';
         $msg->addPart($xmlPart);
         $this->_httpClient->setHeaders('Content-Type', 'multipart/mixed; boundary="' . $msg->getMime()->boundary() . '"');
         $this->_httpClient->setRawData($msg->generateMessage());
         $res = $this->_httpClient->request();
         $this->assertEquals(200, $res->getStatus());
         $obj = json_decode($res->getBody());
         $this->assertTrue(is_object($obj));
         $this->assertNotEmpty($obj->customerData);
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:28,代码来源:PreinventoryExternalTest.php


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