本文整理汇总了PHP中Zend\Mime\Message::createFromMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::createFromMessage方法的具体用法?PHP Message::createFromMessage怎么用?PHP Message::createFromMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mime\Message
的用法示例。
在下文中一共展示了Message::createFromMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeMtomSoapMessage
protected function initializeMtomSoapMessage(array $contentTypeHeader, $content)
{
if (!isset($contentTypeHeader['start']) || !isset($contentTypeHeader['start-info']) || !isset($contentTypeHeader['boundary'])) {
throw new \InvalidArgumentException();
}
$mimeMessage = Message::createFromMessage($content, $contentTypeHeader['boundary']);
$mimeParts = $mimeMessage->getParts();
$soapMimePartId = trim($contentTypeHeader['start'], '<>');
$soapMimePartType = $contentTypeHeader['start-info'];
$rootPart = array_shift($mimeParts);
$rootPartType = $this->splitContentTypeHeader($rootPart->type);
// TODO: add more checks to achieve full compatibility to MTOM spec
// http://www.w3.org/TR/soap12-mtom/
if ($rootPart->id != $soapMimePartId || $rootPartType['_type'] != 'application/xop+xml' || $rootPartType['type'] != $soapMimePartType) {
throw new \InvalidArgumentException();
}
foreach ($mimeParts as $mimePart) {
$this->soapAttachments->add(new SoapAttachment($mimePart->id, $mimePart->type, $mimePart->getContent()));
}
// handle content decoding / prevent encoding
return $rootPart->getContent();
}
示例2: 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 = 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);
}
示例3: testFromMessageDecode
/**
* @dataProvider dataTestFromMessageDecode
*/
public function testFromMessageDecode($input, $encoding, $result)
{
$parts = Mime\Message::createFromMessage('--089e0141a1902f83ee04e0a07b7a' . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n" . 'Content-Transfer-Encoding: ' . $encoding . "\r\n" . "\r\n" . $result . "\r\n" . '--089e0141a1902f83ee04e0a07b7a--', '089e0141a1902f83ee04e0a07b7a')->getParts();
$this->assertSame($input . "\n", $parts[0]->getRawContent());
}