本文整理汇总了PHP中Horde_Imap_Client_Fetch_Query::envelope方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Imap_Client_Fetch_Query::envelope方法的具体用法?PHP Horde_Imap_Client_Fetch_Query::envelope怎么用?PHP Horde_Imap_Client_Fetch_Query::envelope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Imap_Client_Fetch_Query
的用法示例。
在下文中一共展示了Horde_Imap_Client_Fetch_Query::envelope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMessages
public function getMessages($from = 0, $count = 2)
{
$total = $this->getTotalMessages();
if ($from + $count > $total) {
$count = $total - $from;
}
$headers = array();
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->flags();
$fetch_query->seq();
$fetch_query->size();
$fetch_query->uid();
$fetch_query->imapDate();
$headers = array_merge($headers, array('importance', 'list-post', 'x-priority'));
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, array('cache' => true, 'peek' => true));
$opt = array('ids' => $from + 1 . ':' . ($from + 1 + $count));
$opt = array();
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$headers = $this->conn->fetch($this->folder_id, $fetch_query, $opt);
ob_start();
// fix for Horde warnings
$messages = array();
foreach ($headers as $message_id => $header) {
$message = new Message($this->conn, $this->folder_id, $message_id);
$message->setInfo($header);
$messages[] = $message->getListArray();
}
ob_clean();
return $messages;
}
示例2: __construct
/**
* Constructor.
*
* @param IMP_Indices $indices The index of the message.
* @param boolean $peek Don't set seen flag?
*/
public function __construct(IMP_Indices $indices, $peek = false)
{
global $injector;
/* Get envelope/header information. We don't use flags in this
* view. */
try {
list($mbox, $uid) = $indices->getSingle();
if (!$uid) {
throw new Exception();
}
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->headers('imp', self::$headersUsed, array('cache' => true, 'peek' => true));
$imp_imap = $mbox->imp_imap;
$imp_imap->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
$ret = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
if (!($ob = $ret->first())) {
throw new Exception();
}
$this->contents = $injector->getInstance('IMP_Factory_Contents')->create($indices);
if (!$peek) {
$this->_loadHeaders();
}
} catch (Exception $e) {
throw new IMP_Exception(_("Requested message not found."));
}
$this->_envelope = $ob->getEnvelope();
$this->_headers = $ob->getHeaders('imp', Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
$this->_indices = $indices;
$this->_peek = $peek;
}
示例3: generate
/**
* Generates a string that can be saved out to an mbox format mailbox file
* for a mailbox (or set of mailboxes), optionally including all
* subfolders of the selected mailbox(es) as well. All mailboxes will be
* output in the same string.
*
* @param mixed $mboxes A mailbox name (UTF-8), or list of mailbox names,
* to generate a mbox file for.
*
* @return resource A stream resource containing the text of a mbox
* format mailbox file.
*/
public function generate($mboxes)
{
$body = fopen('php://temp', 'r+');
if (!is_array($mboxes)) {
if (!strlen($mboxes)) {
return $body;
}
$mboxes = array($mboxes);
}
if (empty($mboxes)) {
return $body;
}
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->imapDate();
$query->headerText(array('peek' => true));
$query->bodyText(array('peek' => true));
foreach (IMP_Mailbox::get($mboxes) as $val) {
$imp_imap = $val->imp_imap;
$slices = $imp_imap->getSlices($val, $imp_imap->getIdsOb(Horde_Imap_Client_Ids::ALL, true));
foreach ($slices as $slice) {
try {
$res = $imp_imap->fetch($val, $query, array('ids' => $slice, 'nocache' => true));
} catch (IMP_Imap_Exception $e) {
continue;
}
foreach ($res as $ptr) {
$from_env = $ptr->getEnvelope()->from;
$from = count($from_env) ? $from_env[0]->bare_address : '<>';
/* We need this long command since some MUAs (e.g. pine)
* require a space in front of single digit days. */
$imap_date = $ptr->getImapDate();
$date = sprintf('%s %2s %s', $imap_date->format('D M'), $imap_date->format('j'), $imap_date->format('H:i:s Y'));
fwrite($body, 'From ' . $from . ' ' . $date . "\r\n");
/* Remove spurious 'From ' line in headers. */
$stream = $ptr->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_STREAM);
while (!feof($stream)) {
$line = fgets($stream);
if (substr($line, 0, 5) != 'From ') {
fwrite($body, $line);
}
}
fwrite($body, "\r\n");
/* Add Body text. */
$stream = $ptr->getBodyText(0, true);
while (!feof($stream)) {
fwrite($body, fread($stream, 8192));
}
fwrite($body, "\r\n");
}
}
}
return $body;
}
示例4: fetchEnvelope
/**
*/
public function fetchEnvelope($indices)
{
if ($GLOBALS['registry']->hasMethod('mail/imapOb')) {
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->uid();
try {
return $GLOBALS['registry']->call('mail/imapOb')->fetch($this->_getMboxOb(), $query, array('ids' => new Horde_Imap_Client_Ids($indices)));
} catch (Horde_Imap_Client_Exception $e) {
}
}
return false;
}
示例5: getMessageIds
/**
*/
public function getMessageIds()
{
if (isset($this->_msgids)) {
return $this->_msgids;
}
$this->_msgids = array();
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$ret = $this->_mbox->imp_imap->fetch($this->_mbox, $query, array('ids' => $this->_ids));
foreach ($ret as $ob) {
$this->_msgids[] = $ob->getEnvelope()->message_id;
}
return $this->_msgids;
}
示例6: clientSort
/**
* Sort search results client side if the server does not support the SORT
* IMAP extension (RFC 5256).
*
* @param Horde_Imap_Client_Ids $res The search results.
* @param array $opts The options to _search().
*
* @return array The sort results.
*
* @throws Horde_Imap_Client_Exception
*/
public function clientSort($res, $opts)
{
if (!count($res)) {
return $res;
}
/* Generate the FETCH command needed. */
$query = new Horde_Imap_Client_Fetch_Query();
foreach ($opts['sort'] as $val) {
switch ($val) {
case Horde_Imap_Client::SORT_ARRIVAL:
$query->imapDate();
break;
case Horde_Imap_Client::SORT_DATE:
$query->imapDate();
$query->envelope();
break;
case Horde_Imap_Client::SORT_CC:
case Horde_Imap_Client::SORT_DISPLAYFROM:
case Horde_Imap_Client::SORT_DISPLAYTO:
case Horde_Imap_Client::SORT_FROM:
case Horde_Imap_Client::SORT_SUBJECT:
case Horde_Imap_Client::SORT_TO:
$query->envelope();
break;
case Horde_Imap_Client::SORT_SIZE:
$query->size();
break;
}
}
if (!count($query)) {
return $res;
}
$mbox = $this->_socket->currentMailbox();
$fetch_res = $this->_socket->fetch($mbox['mailbox'], $query, array('ids' => $res));
return $this->_clientSortProcess($res->ids, $fetch_res, $opts['sort']);
}
示例7: getMessages
public function getMessages($from = 0, $count = 2, $filter = '')
{
if ($filter instanceof Horde_Imap_Client_Search_Query) {
$query = $filter;
} else {
$query = new Horde_Imap_Client_Search_Query();
if ($filter) {
$query->text($filter, false);
}
}
if ($this->getSpecialRole() !== 'trash') {
$query->flag(Horde_Imap_Client::FLAG_DELETED, false);
}
$result = $this->conn->search($this->mailBox, $query, ['sort' => [Horde_Imap_Client::SORT_DATE]]);
$ids = array_reverse($result['match']->ids);
if ($from >= 0 && $count >= 0) {
$ids = array_slice($ids, $from, $count);
}
$ids = new \Horde_Imap_Client_Ids($ids, false);
$headers = [];
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->flags();
$fetch_query->size();
$fetch_query->uid();
$fetch_query->imapDate();
$fetch_query->structure();
$headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, ['cache' => true, 'peek' => true]);
$options = ['ids' => $ids];
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$headers = $this->conn->fetch($this->mailBox, $fetch_query, $options);
ob_start();
// fix for Horde warnings
$messages = [];
foreach ($headers->ids() as $message_id) {
$header = $headers[$message_id];
$message = new Message($this->conn, $this->mailBox, $message_id, $header);
$messages[] = $message->getListArray();
}
ob_get_clean();
// sort by time
usort($messages, function ($a, $b) {
return $a['dateInt'] < $b['dateInt'];
});
return $messages;
}
示例8: __get
/**
*/
public function __get($name)
{
switch ($name) {
case 'indices':
return $this->_indices;
case 'msgid':
if (!$this->_msgid) {
list($mbox, $uid) = $this->indices->getSingle();
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$imp_imap = $mbox->imp_imap;
$ret = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
$this->_msgid = ($ob = $ret->first()) ? $ob->getEnvelope()->message_id : '';
}
return $this->_msgid;
}
}
示例9: _content
/**
*/
protected function _content()
{
$inbox = IMP_Mailbox::get('INBOX');
/* Filter on INBOX display, if requested. */
$inbox->filterOnDisplay();
$query = new Horde_Imap_Client_Search_Query();
$query->flag(Horde_Imap_Client::FLAG_SEEN, false);
$ids = $inbox->runSearchQuery($query, Horde_Imap_Client::SORT_SEQUENCE, 1);
$indices = $ids['INBOX'];
$html = '<table cellspacing="0" width="100%">';
$text = _("Go to your Inbox...");
if (empty($indices)) {
$html .= '<tr><td><em>' . _("No unread messages") . '</em></td></tr>';
} else {
$imp_ui = new IMP_Mailbox_Ui($inbox);
$shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown'];
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
try {
$imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create($inbox);
$fetch_ret = $imp_imap->fetch($inbox, $query, array('ids' => $imp_imap->getIdsOb(array_slice($indices, 0, $shown))));
} catch (IMP_Imap_Exception $e) {
$fetch_ret = new Horde_Imap_Client_Fetch_Results();
}
foreach ($fetch_ret as $uid => $ob) {
$envelope = $ob->getEnvelope();
$date = $imp_ui->getDate(isset($envelope->date) ? $envelope->date : null);
$from = $imp_ui->getFrom($envelope);
$subject = $imp_ui->getSubject($envelope->subject, true);
$html .= '<tr style="cursor:pointer" class="text"><td>' . $inbox->url('message', $uid)->link() . '<strong>' . htmlspecialchars($from['from'], ENT_QUOTES, 'UTF-8') . '</strong><br />' . $subject . '</a></td>' . '<td>' . htmlspecialchars($date, ENT_QUOTES, 'UTF-8') . '</td></tr>';
}
$more_msgs = count($indices) - $shown;
if ($more_msgs > 0) {
$text = sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs);
}
}
return $html . '<tr><td colspan="2" style="cursor:pointer" align="right">' . $inbox->url('mailbox')->link() . $text . '</a></td></tr>' . '</table>';
}
示例10: getmsg
private function getmsg()
{
$headers = array();
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
// $fetch_query->fullText();
$fetch_query->bodyText();
$fetch_query->flags();
$fetch_query->seq();
$fetch_query->size();
$fetch_query->uid();
$fetch_query->imapDate();
$headers = array_merge($headers, array('importance', 'list-post', 'x-priority'));
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, array('cache' => true, 'peek' => true));
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->message_id);
$headers = $this->conn->fetch($this->folder_id, $fetch_query, array('ids' => $ids));
$this->plainmsg = $headers[$this->message_id]->getBodyText();
//
// // HEADER
// $this->header = $this->conn->fetchHeader($this->folder_id, $this->message_id);
//
// // BODY
// $bodystructure= $this->conn->getStructure($this->folder_id, $this->message_id);
// $a= \rcube_imap_generic::getStructurePartData($bodystructure, 0);
// if ($a['type'] == 'multipart') {
// for ($i=0; $i < count($bodystructure); $i++) {
// if (!is_array($bodystructure[$i]))
// break;
// $this->getpart($bodystructure[$i],$i+1);
// }
// } else {
// // get part no 1
// $this->getpart($bodystructure,1);
// }
}
示例11: _init
/**
* URL Parameters:
* a: (string) Action ID.
* allto: (boolean) View all To addresses?
* buid: (string) Browser UID.
* t: (string) Token.
*/
protected function _init()
{
global $injector, $notification, $page_output, $prefs, $session;
$imp_mailbox = $this->indices->mailbox->list_ob;
$imp_mailbox->setIndex($this->indices);
$mailbox_url = IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox));
/* Make sure we have a valid index. */
if (!$imp_mailbox->isValidIndex()) {
$mailbox_url->add('a', 'm')->redirect();
}
$imp_ui = $injector->getInstance('IMP_Message_Ui');
/* Run through action handlers */
$msg_delete = false;
switch ($this->vars->a) {
// 'd' = delete message
case 'd':
$old_index = $imp_mailbox->getIndex();
try {
$session->checkToken($this->vars->t);
$msg_delete = (bool) $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox));
} catch (Horde_Exception $e) {
$notification->push($e);
}
break;
// 'u' = undelete message
// 'u' = undelete message
case 'u':
$old_index = $imp_mailbox->getIndex();
$injector->getInstance('IMP_Message')->undelete($this->indices);
break;
// 'rs' = report spam
// 'ri' = report innocent
// 'rs' = report spam
// 'ri' = report innocent
case 'rs':
case 'ri':
$old_index = $imp_mailbox->getIndex();
$msg_delete = $injector->getInstance('IMP_Factory_Spam')->create($this->vars->a == 'rs' ? IMP_Spam::SPAM : IMP_Spam::INNOCENT)->report($this->indices, array('mailboxob' => $imp_mailbox)) === 1;
break;
}
if ($msg_delete && $imp_ui->moveAfterAction($this->indices->mailbox)) {
$imp_mailbox->setIndex(1);
}
/* We may have done processing that has taken us past the end of the
* message array, so we will return to the mailbox. */
if (!$imp_mailbox->isValidIndex() || $msg_delete && $prefs->getValue('mailbox_return')) {
$mailbox_url->add('s', $old_index)->redirect();
}
/* Now that we are done processing, get the index and array index of
* the current message. */
$msg_index = $imp_mailbox[$imp_mailbox->getIndex()];
$mailbox = $msg_index['m'];
$uid = $msg_index['u'];
$buid = $imp_mailbox->getBuid($mailbox, $uid);
/* Get envelope/flag/header information. */
try {
$imp_imap = $mailbox->imp_imap;
/* Need to fetch flags before HEADERTEXT, because SEEN flag might
* be set before we can grab it. */
$query = new Horde_Imap_Client_Fetch_Query();
$query->flags();
$flags_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$fetch_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
} catch (IMP_Imap_Exception $e) {
$mailbox_url->add('a', 'm')->redirect();
}
$envelope = $fetch_ret->first()->getEnvelope();
$flags = $flags_ret->first()->getFlags();
/* Parse the message. */
try {
$imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
$mime_headers = $imp_contents->getHeaderAndMarkAsSeen();
} catch (IMP_Exception $e) {
$mailbox_url->add('a', 'm')->redirect();
}
/* Get the starting index for the current message and the message
* count. */
$msgindex = $imp_mailbox->getIndex();
$msgcount = count($imp_mailbox);
/* Generate the mailbox link. */
$mailbox_link = $mailbox_url->add('s', $msgindex);
$self_link = self::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox));
/* Create the Identity object. */
$user_identity = $injector->getInstance('IMP_Identity');
/* Develop the list of headers to display. */
$basic_headers = $imp_ui->basicHeaders();
$display_headers = $msgAddresses = array();
if ($subject = $mime_headers->getValue('subject')) {
/* Filter the subject text, if requested. */
$subject = Horde_String::truncate(IMP::filterText($subject), 50);
} else {
//.........这里部分代码省略.........
示例12: _thread
/**
* @throws Horde_Imap_Client_Exception_NoSupportExtension
*/
protected function _thread($options)
{
$thread_criteria = array(Horde_Imap_Client::THREAD_ORDEREDSUBJECT => 'ORDEREDSUBJECT', Horde_Imap_Client::THREAD_REFERENCES => 'REFERENCES', Horde_Imap_Client::THREAD_REFS => 'REFS');
$tsort = isset($options['criteria']) ? is_string($options['criteria']) ? strtoupper($options['criteria']) : $thread_criteria[$options['criteria']] : 'ORDEREDSUBJECT';
$cap = $this->queryCapability('THREAD');
if (!$cap || !in_array($tsort, $cap)) {
switch ($tsort) {
case 'ORDEREDSUBJECT':
if (empty($options['search'])) {
$ids = $this->getIdsOb(Horde_Imap_Client_Ids::ALL, !empty($options['sequence']));
} else {
$search_res = $this->search($this->_selected, $options['search'], array('sequence' => !empty($options['sequence'])));
$ids = $search_res['match'];
}
/* Do client-side ORDEREDSUBJECT threading. */
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->imapDate();
$fetch_res = $this->fetch($this->_selected, $query, array('ids' => $ids));
if (!isset($this->_temp['clientsort'])) {
$this->_temp['clientsort'] = new Horde_Imap_Client_Socket_ClientSort($this);
}
return $this->_temp['clientsort']->threadOrderedSubject($fetch_res, empty($options['sequence']));
case 'REFERENCES':
case 'REFS':
throw new Horde_Imap_Client_Exception_NoSupportExtension('THREAD', sprintf('Server does not support "%s" thread sort.', $tsort));
}
}
$cmd = $this->_command(empty($options['sequence']) ? 'UID THREAD' : 'THREAD')->add($tsort);
if (empty($options['search'])) {
$cmd->add(array('US-ASCII', 'ALL'));
} else {
$search_query = $options['search']->build();
$cmd->add(is_null($search_query['charset']) ? 'US-ASCII' : $search_query['charset']);
$cmd->add($search_query['query'], true);
}
return new Horde_Imap_Client_Data_Thread($this->_sendCmd($cmd)->data['threadparse'], empty($options['sequence']) ? 'uid' : 'sequence');
}
示例13: getMailboxArray
/**
* Build the array of message information.
*
* @param array $msgnum An array of index numbers.
* @param array $options Additional options:
* - headers: (boolean) Return info on the non-envelope headers
* 'Importance', 'List-Post', and 'X-Priority'.
* DEFAULT: false (only envelope headers returned)
* - preview: (mixed) Include preview information? If empty, add no
* preview information. If 1, uses value from prefs.
* If 2, forces addition of preview info.
* DEFAULT: No preview information.
* - type: (boolean) Return info on the MIME Content-Type of the base
* message part ('Content-Type' header).
* DEFAULT: false
*
* @return array An array with the following keys:
* - overview: (array) The overview information. Contains the following:
* - envelope: (Horde_Imap_Client_Data_Envelope) Envelope information
* returned from the IMAP server.
* - flags: (array) The list of IMAP flags returned from the server.
* - headers: (array) Horde_Mime_Headers objects containing header data
* if either $options['headers'] or $options['type'] are
* true.
* - idx: (integer) Array index of this message.
* - mailbox: (string) The mailbox containing the message.
* - preview: (string) If requested in $options['preview'], the preview
* text.
* - previewcut: (boolean) Has the preview text been cut?
* - size: (integer) The size of the message in bytes.
* - uid: (string) The unique ID of the message.
* - uids: (IMP_Indices) An indices object.
*/
public function getMailboxArray($msgnum, $options = array())
{
$this->_buildMailbox();
$headers = $overview = $to_process = $uids = array();
/* Build the list of mailboxes and messages. */
foreach ($msgnum as $i) {
/* Make sure that the index is actually in the slice of messages
we're looking at. If we're hiding deleted messages, for
example, there may be gaps here. */
if (isset($this->_sorted[$i - 1])) {
$to_process[strval($this->_getMbox($i - 1))][$i] = $this->_sorted[$i - 1];
}
}
$fetch_query = new Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->flags();
$fetch_query->size();
$fetch_query->uid();
if (!empty($options['headers'])) {
$headers = array_merge($headers, array('importance', 'list-post', 'x-priority'));
}
if (!empty($options['type'])) {
$headers[] = 'content-type';
}
if (!empty($headers)) {
$fetch_query->headers('imp', $headers, array('cache' => true, 'peek' => true));
}
if (empty($options['preview'])) {
$cache = null;
$options['preview'] = 0;
} else {
$cache = $this->_mailbox->imp_imap->getCache();
}
/* Retrieve information from each mailbox. */
foreach ($to_process as $mbox => $ids) {
try {
$imp_imap = IMP_Mailbox::get($mbox)->imp_imap;
$fetch_res = $imp_imap->fetch($mbox, $fetch_query, array('ids' => $imp_imap->getIdsOb($ids)));
if ($options['preview']) {
$preview_info = $tostore = array();
if ($cache) {
try {
$preview_info = $cache->get($mbox, $ids, array('IMPpreview', 'IMPpreviewc'));
} catch (IMP_Imap_Exception $e) {
}
}
}
$mbox_ids = array();
foreach ($ids as $k => $v) {
if (!isset($fetch_res[$v])) {
continue;
}
$f = $fetch_res[$v];
$uid = $f->getUid();
$v = array('envelope' => $f->getEnvelope(), 'flags' => $f->getFlags(), 'headers' => $f->getHeaders('imp', Horde_Imap_Client_Data_Fetch::HEADER_PARSE), 'idx' => $k, 'mailbox' => $mbox, 'size' => $f->getSize(), 'uid' => $uid);
if ($options['preview'] === 2 || $options['preview'] === 1 && (!$GLOBALS['prefs']->getValue('preview_show_unread') || !in_array(Horde_Imap_Client::FLAG_SEEN, $v['flags']))) {
if (empty($preview_info[$uid])) {
try {
$imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $uid));
$prev = $imp_contents->generatePreview();
$preview_info[$uid] = array('IMPpreview' => $prev['text'], 'IMPpreviewc' => $prev['cut']);
if (!is_null($cache)) {
$tostore[$uid] = $preview_info[$uid];
}
} catch (Exception $e) {
$preview_info[$uid] = array('IMPpreview' => '', 'IMPpreviewc' => false);
}
//.........这里部分代码省略.........
示例14: testSimpleFetch
/**
* @depends testOptimizedSearches
*/
public function testSimpleFetch()
{
$simple_fetch = new Horde_Imap_Client_Fetch_Query();
$simple_fetch->structure();
$simple_fetch->envelope();
$simple_fetch->imapDate();
$simple_fetch->size();
$simple_fetch->flags();
// Simple fetch example.
$res = self::$live->fetch(self::$test_mbox, $simple_fetch, array('ids' => new Horde_Imap_Client_Ids(1, true)));
$this->assertInstanceOf('Horde_Imap_Client_Fetch_Results', $res);
$this->assertEquals(1, count($res));
$this->assertInstanceOf('Horde_Imap_Client_Data_Envelope', $res[1]->getEnvelope());
$this->assertEquals('Test e-mail 1', $res[1]->getEnvelope()->subject);
}
示例15: loadMessageBodies
private function loadMessageBodies()
{
$headers = [];
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->structure();
$fetch_query->flags();
$fetch_query->size();
$fetch_query->imapDate();
$headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, ['cache' => true, 'peek' => true]);
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->messageId);
$headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
/** @var $fetch \Horde_Imap_Client_Data_Fetch */
$fetch = $headers[$this->messageId];
if (is_null($fetch)) {
throw new DoesNotExistException("This email ({$this->messageId}) can't be found. Probably it was deleted from the server recently. Please reload.");
}
// set $this->fetch to get to, from ...
$this->fetch = $fetch;
// analyse the body part
$structure = $fetch->getStructure();
// debugging below
$structure_type = $structure->getPrimaryType();
if ($structure_type == 'multipart') {
$i = 1;
foreach ($structure->getParts() as $p) {
$this->getPart($p, $i++);
}
} else {
if ($structure->findBody() != null) {
// get the body from the server
$partId = $structure->findBody();
$this->getPart($structure->getPart($partId), $partId);
}
}
}