本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}