本文整理汇总了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);
}
}
示例2: setBoundary
/**
* {@inheritdoc}
*
* @return $this|self
*/
public function setBoundary($boundary) : self
{
$this->message->setBoundary($boundary);
return $this;
}