本文整理汇总了PHP中Horde_Mime_Part::parseMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::parseMessage方法的具体用法?PHP Horde_Mime_Part::parseMessage怎么用?PHP Horde_Mime_Part::parseMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::parseMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testvTodo
/**
* @requires extension bcmath
*/
public function testvTodo()
{
$tnef = Horde_Compress::factory('Tnef');
$mime = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/fixtures/tnef_task.eml'));
try {
$tnef_data = $tnef->decompress($mime->getPart(2)->getContents());
} catch (Horde_Mapi_Exception $e) {
$this->markTestSkipped('Horde_Mapi is not available');
} catch (Horde_Compress_Exception $e) {
var_dump($e);
}
// Test the generated iCalendar.
$iCal = new Horde_Icalendar();
if (!$iCal->parsevCalendar($tnef_data[0]['stream'])) {
throw new Horde_Compress_Exception(_("There was an error importing the iCalendar data."));
}
$this->assertEquals($iCal->getAttribute('METHOD'), 'REQUEST');
$components = $iCal->getComponents();
if (count($components) == 0) {
throw new Horde_Compress_Exception(_("No iCalendar data was found."));
}
$vTodo = current($components);
$this->assertEquals($vTodo->getAttribute('SUMMARY'), 'Test Task');
$this->assertEquals($vTodo->getAttribute('UID'), 'EDF71E6FA6FB69A79D79FE1D6DCDBBD300000000DFD9B6FB');
$this->assertEquals($vTodo->getAttribute('ATTENDEE'), 'Michael Rubinsky <mrubinsk@horde.org>');
$params = $vTodo->getAttribute('ATTENDEE', true);
if (!$params) {
throw new Horde_Compress_Exception('Could not find expected parameters.');
}
$this->assertEquals($params[0]['ROLE'], 'REQ-PARTICIPANT');
$this->assertEquals($vTodo->getAttribute('ORGANIZER'), 'mailto: mike@theupstairsroom.com');
}
示例2: test_messageinbound_handler_trim
/**
* @dataProvider message_inbound_handler_trim_testprovider
*/
public function test_messageinbound_handler_trim($file, $source, $expectedplain, $expectedhtml)
{
$this->resetAfterTest();
$mime = Horde_Mime_Part::parseMessage($source);
if ($plainpartid = $mime->findBody('plain')) {
$messagedata = new stdClass();
$messagedata->plain = $mime->getPart($plainpartid)->getContents();
$messagedata->html = '';
list($message, $format) = test_handler::remove_quoted_text($messagedata);
list($message, $expectedplain) = preg_replace("#\r\n#", "\n", array($message, $expectedplain));
// Normalise line endings on both strings.
$this->assertEquals($expectedplain, $message);
$this->assertEquals(FORMAT_PLAIN, $format);
}
if ($htmlpartid = $mime->findBody('html')) {
$messagedata = new stdClass();
$messagedata->plain = '';
$messagedata->html = $mime->getPart($htmlpartid)->getContents();
list($message, $format) = test_handler::remove_quoted_text($messagedata);
// Normalise line endings on both strings.
list($message, $expectedhtml) = preg_replace("#\r\n#", "\n", array($message, $expectedhtml));
$this->assertEquals($expectedhtml, $message);
$this->assertEquals(FORMAT_PLAIN, $format);
}
}
示例3: testIconvHtmlMessage
public function testIconvHtmlMessage()
{
$conn = $this->getMockBuilder('Horde_Imap_Client_Socket')->disableOriginalConstructor()->setMethods(['fetch'])->getMock();
$urlGenerator = $this->getMockBuilder('\\OCP\\IURLGenerator')->disableOriginalConstructor()->getMock();
//linkToRoute 'mail.proxy.proxy'
$urlGenerator->expects($this->any())->method('linkToRoute')->will($this->returnCallback(function ($url) {
return "https://docs.example.com/server/go.php?to={$url}";
}));
$htmlService = new \OCA\Mail\Service\Html($urlGenerator);
// mock first fetch
$firstFetch = new Horde_Imap_Client_Data_Fetch();
$firstPart = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/data/mail-message-123.txt'), ['level' => 1]);
$firstFetch->setStructure($firstPart);
$firstFetch->setBodyPart(1, $firstPart->getPart(1)->getContents());
$firstFetch->setBodyPart(2, $firstPart->getPart(2)->getContents());
$firstResult = new Horde_Imap_Client_Fetch_Results();
$firstResult[123] = $firstFetch;
$conn->expects($this->any())->method('fetch')->willReturn($firstResult);
$message = new \OCA\Mail\Message($conn, 'INBOX', 123, null, true, $htmlService);
$htmlBody = $message->getHtmlBody(0, 0, 123, function () {
return null;
});
$this->assertTrue(strlen($htmlBody) > 1000);
$plainTextBody = $message->getPlainBody();
$this->assertTrue(strlen($plainTextBody) > 1000);
}
示例4: testInvite
/**
* Test creating a Horde_ActiveSync_Message_MeetingRequest from a MIME Email
*/
public function testInvite()
{
$this->markTestIncomplete('Has issues on 32bit systems');
$fixture = file_get_contents(__DIR__ . '/fixtures/invitation_one.eml');
$mime = Horde_Mime_Part::parseMessage($fixture);
$msg = new Horde_ActiveSync_Message_MeetingRequest();
foreach ($mime->contentTypeMap() as $id => $type) {
if ($type == 'text/calendar') {
$vcal = new Horde_Icalendar();
$vcal->parseVcalendar($mime->getPart($id)->getContents());
$msg->fromvEvent($vcal);
break;
}
}
$stream = fopen('php://memory', 'wb+');
$encoder = new Horde_ActiveSync_Wbxml_Encoder($stream);
$msg->encodeStream($encoder);
rewind($stream);
$results = stream_get_contents($stream);
fclose($stream);
$stream = fopen(__DIR__ . '/fixtures/meeting_request_one.wbxml', 'r+');
$expected = '';
// Using file_get_contents or even fread mangles the binary data for some
// reason.
while ($line = fgets($stream)) {
$expected .= $line;
}
fclose($stream);
$this->assertEquals($expected, $results);
}
示例5: testHasiCalendar
public function testHasiCalendar()
{
$fixture = file_get_contents(__DIR__ . '/fixtures/invitation_one.eml');
$mime = new Horde_ActiveSync_Mime(Horde_Mime_Part::parseMessage($fixture));
$this->assertEquals(true, $mime->hasAttachments());
$this->assertEquals(false, $mime->isSigned());
$this->assertEquals(true, (bool) $mime->hasiCalendar());
}
示例6: testReplace
public function testReplace()
{
$part = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/fixtures/related_msg.txt'));
$related = new Horde_Mime_Related($part);
$ob = $related->cidReplace($part['1']->getContents(), array($this, 'callbackTestReplace'));
$body = $ob->dom->getElementsByTagName('body');
$this->assertEquals(1, $body->length);
$this->assertEquals('2', $body->item(0)->getAttribute('background'));
$body = $ob->dom->getElementsByTagName('img');
$this->assertEquals(1, $body->length);
$this->assertEquals('3', $body->item(0)->getAttribute('src'));
}
示例7: fetchComplete
/**
* Retrieves a complete message.
*
* @param string $folder The folder to fetch the messages from.
* @param array $uid The message UID.
*
* @return array The message encapsuled as an array that contains a
* Horde_Mime_Headers and a Horde_Mime_Part object.
*/
public function fetchComplete($folder, $uid)
{
$query = new Horde_Imap_Client_Fetch_Query();
$query->fullText();
try {
$ret = $this->getBackend()->fetch($folder, $query, array('ids' => new Horde_Imap_Client_Ids($uid)));
if (!isset($ret[$uid])) {
throw new Horde_Kolab_Storage_Exception(sprintf(Horde_Kolab_Storage_Translation::t("Failed fetching message %s in folder %s."), $uid, $folder));
}
$msg = $ret[$uid]->getFullMsg();
} catch (Horde_Imap_Client_Exception_ServerResponse $e) {
throw new Horde_Kolab_Storage_Exception($e->details);
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Kolab_Storage_Exception($e);
}
return array(Horde_Mime_Headers::parseHeaders($msg), Horde_Mime_Part::parseMessage($msg));
}
示例8: _getMimeMessage
private function _getMimeMessage()
{
$mail = $this->_getMail();
return Horde_Mime_Part::parseMessage($mail);
}
示例9: _fetch
//.........这里部分代码省略.........
case Horde_Imap_Client::FETCH_BODYTEXT:
// Ignore 'peek' option
foreach ($c_val as $key => $val) {
foreach ($seq_ids as $id) {
try {
$results->get($lookup[$id])->setBodyText($key, $this->_processString(Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $id)), 'body', $key), $val));
} catch (Horde_Mime_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_MIMEHEADER:
// Ignore 'peek' option
foreach ($c_val as $key => $val) {
foreach ($seq_ids as $id) {
try {
$results->get($lookup[$id])->setMimeHeader($key, $this->_processString(Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $id)), 'header', $key), $val));
} catch (Horde_Mime_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_BODYPART:
// Ignore 'decode', 'peek'
foreach ($c_val as $key => $val) {
foreach ($seq_ids as $id) {
try {
$results->get($lookup[$id])->setBodyPart($key, $this->_processString(Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $id)), 'body', $key), $val));
} catch (Horde_Mime_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_HEADERS:
// Ignore 'length', 'peek'
foreach ($seq_ids as $id) {
$ob = $this->_pop3Cache('hdrob', $id);
foreach ($c_val as $key => $val) {
$tmp = $ob;
if (empty($val['notsearch'])) {
$tmp2 = $tmp->toArray(array('nowrap' => true));
foreach (array_keys($tmp2) as $hdr) {
if (!in_array($hdr, $val['headers'])) {
$tmp->removeHeader($hdr);
}
}
} else {
foreach ($val['headers'] as $hdr) {
$tmp->removeHeader($hdr);
}
}
$results->get($lookup[$id])->setHeaders($key, $tmp);
}
}
break;
case Horde_Imap_Client::FETCH_STRUCTURE:
foreach ($seq_ids as $id) {
if ($ptr = $this->_pop3Cache('msg', $id)) {
try {
$results->get($lookup[$id])->setStructure(Horde_Mime_Part::parseMessage(stream_get_contents($ptr)));
} catch (Horde_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_ENVELOPE:
foreach ($seq_ids as $id) {
$tmp = $this->_pop3Cache('hdrob', $id);
$results->get($lookup[$id])->setEnvelope(array('date' => $tmp->getValue('date'), 'subject' => $tmp->getValue('subject'), 'from' => $tmp->getOb('from'), 'sender' => $tmp->getOb('sender'), 'reply_to' => $tmp->getOb('reply-to'), 'to' => $tmp->getOb('to'), 'cc' => $tmp->getOb('cc'), 'bcc' => $tmp->getOb('bcc'), 'in_reply_to' => $tmp->getValue('in-reply-to'), 'message_id' => $tmp->getValue('message-id')));
}
break;
case Horde_Imap_Client::FETCH_IMAPDATE:
foreach ($seq_ids as $id) {
$tmp = $this->_pop3Cache('hdrob', $id);
$results->get($lookup[$id])->setImapDate($tmp->getValue('date'));
}
break;
case Horde_Imap_Client::FETCH_SIZE:
$sizelist = $this->_pop3Cache('size');
foreach ($seq_ids as $id) {
$results->get($lookup[$id])->setSize($sizelist[$id]);
}
break;
case Horde_Imap_Client::FETCH_SEQ:
foreach ($seq_ids as $id) {
$results->get($lookup[$id])->setSeq($id);
}
break;
case Horde_Imap_Client::FETCH_UID:
$uidllist = $this->_pop3Cache('uidl');
foreach ($seq_ids as $id) {
if (isset($uidllist[$id])) {
$results->get($lookup[$id])->setUid($uidllist[$id]);
}
}
break;
}
}
$this->_updateCache($results, array('seq' => $options['ids']->sequence));
}
示例10: _fetchCmd
//.........这里部分代码省略.........
break;
case Horde_Imap_Client::FETCH_BODYTEXT:
// Ignore 'peek' option
foreach ($c_val as $key => $val) {
foreach ($seq_ids as $id) {
try {
$results->get($lookup[$id])->setBodyText($key, $this->_processString(Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $id)), 'body', $key), $val));
} catch (Horde_Mime_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_MIMEHEADER:
// Ignore 'peek' option
foreach ($c_val as $key => $val) {
foreach ($seq_ids as $id) {
try {
$results->get($lookup[$id])->setMimeHeader($key, $this->_processString(Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $id)), 'header', $key), $val));
} catch (Horde_Mime_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_BODYPART:
// Ignore 'decode', 'peek'
foreach ($c_val as $key => $val) {
foreach ($seq_ids as $id) {
try {
$results->get($lookup[$id])->setBodyPart($key, $this->_processString(Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $id)), 'body', $key), $val));
} catch (Horde_Mime_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_HEADERS:
// Ignore 'length', 'peek'
foreach ($seq_ids as $id) {
$ob = $this->_pop3Cache('hdrob', $id);
foreach ($c_val as $key => $val) {
$tmp = $ob;
if (empty($val['notsearch'])) {
$tmp2 = $tmp->toArray(array('nowrap' => true));
foreach (array_keys($tmp2) as $hdr) {
if (!in_array($hdr, $val['headers'])) {
unset($tmp[$hdr]);
}
}
} else {
foreach ($val['headers'] as $hdr) {
unset($tmp[$hdr]);
}
}
$results->get($lookup[$id])->setHeaders($key, $tmp);
}
}
break;
case Horde_Imap_Client::FETCH_STRUCTURE:
foreach ($seq_ids as $id) {
if ($ptr = $this->_pop3Cache('msg', $id)) {
try {
$results->get($lookup[$id])->setStructure(Horde_Mime_Part::parseMessage(stream_get_contents($ptr), array('no_body' => true)));
} catch (Horde_Exception $e) {
}
}
}
break;
case Horde_Imap_Client::FETCH_ENVELOPE:
foreach ($seq_ids as $id) {
$tmp = $this->_pop3Cache('hdrob', $id);
$results->get($lookup[$id])->setEnvelope(array('date' => $tmp['Date'], 'subject' => $tmp['Subject'], 'from' => ($h = $tmp['From']) ? $h->getAddressList(true) : null, 'sender' => ($h = $tmp['Sender']) ? $h->getAddressList(true) : null, 'reply_to' => ($h = $tmp['Reply-to']) ? $h->getAddressList(true) : null, 'to' => ($h = $tmp['To']) ? $h->getAddressList(true) : null, 'cc' => ($h = $tmp['Cc']) ? $h->getAddressList(true) : null, 'bcc' => ($h = $tmp['Bcc']) ? $h->getAddressList(true) : null, 'in_reply_to' => $tmp['In-Reply-To'], 'message_id' => $tmp['Message-ID']));
}
break;
case Horde_Imap_Client::FETCH_IMAPDATE:
foreach ($seq_ids as $id) {
$tmp = $this->_pop3Cache('hdrob', $id);
$results->get($lookup[$id])->setImapDate($tmp['Date']);
}
break;
case Horde_Imap_Client::FETCH_SIZE:
$sizelist = $this->_pop3Cache('size');
foreach ($seq_ids as $id) {
$results->get($lookup[$id])->setSize($sizelist[$id]);
}
break;
case Horde_Imap_Client::FETCH_SEQ:
foreach ($seq_ids as $id) {
$results->get($lookup[$id])->setSeq($id);
}
break;
case Horde_Imap_Client::FETCH_UID:
$uidllist = $this->_pop3Cache('uidl');
foreach ($seq_ids as $id) {
if (isset($uidllist[$id])) {
$results->get($lookup[$id])->setUid($uidllist[$id]);
}
}
break;
}
}
}
示例11: _parseSignedData
/**
* Parse signed data.
*
* @param boolean $sig_only Only do signature checking?
*
* @return mixed See self::_getEmbeddedMimeParts().
*/
protected function _parseSignedData($sig_only = false)
{
$partlist = array_keys($this->_mimepart->contentTypeMap());
$base_id = reset($partlist);
$data_id = next($partlist);
$sig_id = Horde_Mime::mimeIdArithmetic($data_id, 'next');
/* Initialize inline data. */
$status = new IMP_Mime_Status(_("The data in this part has been digitally signed via S/MIME."));
$status->icon('mime/encryption.png', 'S/MIME');
$cache = $this->getConfigParam('imp_contents')->getViewCache();
$cache->smime[$base_id] = array('sig' => $sig_id, 'status' => $status, 'wrap' => 'mimePartWrap');
if (!$GLOBALS['prefs']->getValue('use_smime')) {
$status->addText(_("S/MIME support is not enabled so the digital signature is unable to be verified."));
return null;
}
/* Sanity checking to make sure MIME structure is correct. */
if (!in_array($sig_id, $partlist)) {
$status->action(IMP_Mime_Status::ERROR);
$cache->smime[$base_id]['wrap'] = 'mimePartWrapInvalid';
$status->addText(_("Invalid S/MIME data."));
/* This will suppress displaying the invalid part. */
$cache->smime[$base_id]['sig'] = $data_id;
return null;
}
$imp_contents = $this->getConfigParam('imp_contents');
$stream = $imp_contents->isEmbedded($base_id) ? $this->_mimepart->getMetadata('imp-smime-decrypt')->stream : $this->_getPartStream($base_id);
$raw_text = $this->_mimepart->replaceEOL($stream, Horde_Mime_Part::RFC_EOL);
$this->_initSmime();
$sig_result = null;
if ($GLOBALS['prefs']->getValue('smime_verify') || $GLOBALS['injector']->getInstance('Horde_Variables')->smime_verify_msg) {
try {
$sig_result = $this->_impsmime->verifySignature($raw_text);
if ($sig_result->verify) {
$status->action(IMP_Mime_Status::SUCCESS);
} else {
$status->action(IMP_Mime_Status::WARNING);
}
$cache->smime[$base_id]['wrap'] = 'mimePartWrapValid';
$email = is_array($sig_result->email) ? implode(', ', $sig_result->email) : $sig_result->email;
$status->addText($sig_result->msg);
if (!empty($sig_result->cert)) {
$cert = $this->_impsmime->parseCert($sig_result->cert);
if (isset($cert['certificate']['subject']['CommonName']) && strcasecmp($email, $cert['certificate']['subject']['CommonName']) !== 0) {
$email = $cert['certificate']['subject']['CommonName'] . ' (' . trim($email) . ')';
}
}
if (!empty($sig_result->cert) && isset($sig_result->email) && $GLOBALS['registry']->hasMethod('contacts/addField') && $GLOBALS['prefs']->getValue('add_source')) {
$status->addText(sprintf(_("Sender: %s"), $imp_contents->linkViewJS($this->_mimepart, 'view_attach', htmlspecialchars(strlen($email) ? $email : $sig_result->email), array('jstext' => _("View certificate details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE, 'view_smime_key' => 1)))));
try {
$this->_impsmime->getPublicKey($sig_result->email);
} catch (Horde_Exception $e) {
$imple = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_ImportEncryptKey', array('mime_id' => $base_id, 'muid' => strval($imp_contents->getIndicesOb()), 'type' => 'smime'));
$status->addText(Horde::link('#', '', '', '', '', '', '', array('id' => $imple->getDomId())) . _("Save the certificate to your Address Book.") . '</a>');
}
} elseif (strlen($email)) {
$status->addText(sprintf(_("Sender: %s"), htmlspecialchars($email)));
}
} catch (Horde_Exception $e) {
$status->action(IMP_Mime_Status::ERROR);
$cache->smime[$base_id]['wrap'] = 'mimePartWrapInvalid';
$status->addText($e->getMessage());
}
} else {
switch ($GLOBALS['registry']->getView()) {
case Horde_Registry::VIEW_BASIC:
$status->addText(Horde::link(Horde::selfUrlParams()->add('smime_verify_msg', 1)) . _("Click HERE to verify the data.") . '</a>');
break;
case Horde_Registry::VIEW_DYNAMIC:
$status->addText(Horde::link('#', '', 'smimeVerifyMsg') . _("Click HERE to verify the data.") . '</a>');
break;
}
}
if ($sig_only) {
return;
}
$subpart = $imp_contents->getMIMEPart($sig_id);
if (empty($subpart)) {
try {
$msg_data = $this->_impsmime->extractSignedContents($raw_text);
$subpart = Horde_Mime_Part::parseMessage($msg_data, array('forcemime' => true));
} catch (Horde_Exception $e) {
$status->addText($e->getMessage());
return null;
}
}
return $subpart;
}
示例12: fetchComplete
/**
* Retrieves a complete message.
*
* @param string $folder The folder to fetch the messages from.
* @param array $uid The message UID.
*
* @return array The message encapsuled as an array that contains a
* Horde_Mime_Headers and a Horde_Mime_Part object.
*/
public function fetchComplete($folder, $uid)
{
$this->select($folder);
return array(Horde_Mime_Headers::parseHeaders(Horde_Kolab_Storage_Exception_Pear::catchError($this->getBackend()->getRawHeaders($uid, '', true))), Horde_Mime_Part::parseMessage(Horde_Kolab_Storage_Exception_Pear::catchError($this->getBackend()->getBody($uid, true))));
}
示例13: parseMessage
/**
* Get an IMAP message and retrieve the Kolab Format object.
*
* @param int $id The message to retrieve.
* @param string $mime_type The mime type of the part to retrieve.
* @param boolean $parse_headers Should the heades be Mime parsed?
* @param array $formats The list of possible format parts.
*
* @return array|PEAR_Error An array that list the Kolab XML
* object text, the mime ID of the part
* with the XML object, the Mime parsed
* message and the Mime parsed headers if
* requested.
*/
function parseMessage($id, $mime_type, $parse_headers = true, $formats = array('XML'))
{
$raw_headers = $this->_driver->getMessageHeader($this->_path, $id);
if (is_a($raw_headers, 'PEAR_Error')) {
return PEAR::raiseError(sprintf(Horde_Kolab_Storage_Translation::t("Failed retrieving the message with ID %s. Original error: %s."), $id, $raw_headers->getMessage()));
}
$body = $this->_driver->getMessageBody($this->_path, $id);
if (is_a($body, 'PEAR_Error')) {
return PEAR::raiseError(sprintf(Horde_Kolab_Storage_Translation::t("Failed retrieving the message with ID %s. Original error: %s."), $id, $body->getMessage()));
}
//@todo: not setting "forcemime" means the subparts get checked too. Seems incorrect.
$mime_message = Horde_Mime_Part::parseMessage($raw_headers . "\r" . $body, array('forcemime' => true));
$parts = $mime_message->contentTypeMap();
$mime_headers = false;
$xml = false;
// Read in a Kolab event object, if one exists
$part_ids['XML'] = array_search($mime_type, $parts);
if ($part_ids['XML'] !== false) {
if ($parse_headers) {
$mime_headers = Horde_Mime_Headers::parseHeaders($raw_headers);
$mime_headers->setEOL("\r\n");
}
$part = $mime_message->getPart($part_ids['XML']);
//@todo: Check what happened to this call
//$part->transferDecodeContents();
$xml = $part->getContents();
}
$alternate_formats = array_diff(array('XML'), $formats);
if (!empty($alternate_formats)) {
foreach ($alternate_formats as $type) {
$part_ids[$type] = false;
}
foreach ($mime_message->getParts() as $part) {
$params = $part->getDispositionParameters();
foreach ($alternate_formats as $type) {
if (isset($params['x-kolab-format']) && $params['x-kolab-format'] == $type) {
$part_ids[$type] = $part->getMimeId();
}
}
}
}
$result = array($xml, $part_ids, $mime_message, $mime_headers);
return $result;
}
示例14: _reEncodeMessageAttachment
/**
* Rebuilds $part and forces it to be a base64 encoded
* application/octet-stream part.
*
* @param Horde_Mime_Part $part The MIME part.
*/
protected function _reEncodeMessageAttachment(Horde_Mime_Part $part)
{
$new_part = Horde_Mime_Part::parseMessage($part->getContents());
$part->setContents($new_part->getContents(array('stream' => true)), array('encoding' => self::ENCODE_BINARY));
$part->setTransferEncoding('base64', array('send' => true));
}
示例15: testBug13117
public function testBug13117()
{
$msg = file_get_contents(__DIR__ . '/fixtures/bug13117.txt');
$part = Horde_Mime_Part::parseMessage($msg);
$this->assertTrue(isset($part['2']));
$this->assertTrue(isset($part['2.0']));
$this->assertTrue(isset($part['2.1']));
$this->assertFalse(isset($part['2.2']));
$multipart = $part['2.0'];
$multipart->addPart(new Horde_Mime_Part());
$multipart->buildMimeIds('2.0');
$this->assertTrue(isset($part['2']));
$this->assertTrue(isset($part['2.0']));
$this->assertTrue(isset($part['2.1']));
$this->assertTrue(isset($part['2.2']));
}