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


PHP Swift_Message::setBoundary方法代码示例

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


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

示例1: streamToMime

 /**
  * Merges an OutputByteStream to Swift_Message.
  *
  * @param Swift_OutputByteStream $fromStream
  * @param Swift_Message          $message
  */
 protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
 {
     $bufferLength = 78;
     $headerData = '';
     $fromStream->setReadPointer(0);
     while (($buffer = $fromStream->read($bufferLength)) !== false) {
         $headerData .= $buffer;
         if (false !== strpos($buffer, "\r\n\r\n")) {
             break;
         }
     }
     $headersPosEnd = strpos($headerData, "\r\n\r\n");
     $headerData = trim($headerData);
     $headerData = substr($headerData, 0, $headersPosEnd);
     $headerLines = explode("\r\n", $headerData);
     unset($headerData);
     $headers = array();
     $currentHeaderName = '';
     foreach ($headerLines as $headerLine) {
         // Line separated
         if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) {
             $headers[$currentHeaderName] .= ' ' . trim($headerLine);
             continue;
         }
         $header = explode(':', $headerLine, 2);
         $currentHeaderName = strtolower($header[0]);
         $headers[$currentHeaderName] = trim($header[1]);
     }
     $messageStream = new Swift_ByteStream_TemporaryFileByteStream();
     $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF');
     $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF');
     $messageHeaders = $message->getHeaders();
     // No need to check for 'application/pkcs7-mime', as this is always base64
     if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) {
         if (!preg_match('/boundary=("[^"]+"|(?:[^\\s]+|$))/is', $headers['content-type'], $contentTypeData)) {
             throw new Swift_SwiftException('Failed to find Boundary parameter');
         }
         $boundary = trim($contentTypeData['1'], '"');
         $boundaryLen = strlen($boundary);
         // Skip the header and CRLF CRLF
         $fromStream->setReadPointer($headersPosEnd + 4);
         while (false !== ($buffer = $fromStream->read($bufferLength))) {
             $messageStream->write($buffer);
         }
         $messageStream->commit();
         $messageHeaders->remove('Content-Transfer-Encoding');
         $message->setContentType($headers['content-type']);
         $message->setBoundary($boundary);
         $message->setBody($messageStream);
     } else {
         $fromStream->setReadPointer($headersPosEnd + 4);
         if (null === $this->headerFactory) {
             $this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory');
         }
         $message->setContentType($headers['content-type']);
         $messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding']));
         $messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition']));
         while (false !== ($buffer = $fromStream->read($bufferLength))) {
             $messageStream->write($buffer);
         }
         $messageStream->commit();
         $message->setBody($messageStream);
     }
 }
开发者ID:NivalM,项目名称:VacantesJannaMotors,代码行数:70,代码来源:SMimeSigner.php

示例2: setBoundary

 /**
  * {@inheritdoc}
  *
  * @return $this|self
  */
 public function setBoundary($boundary) : self
 {
     $this->message->setBoundary($boundary);
     return $this;
 }
开发者ID:cawaphp,项目名称:email,代码行数:10,代码来源:Message.php


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