size() public method

Return the size (in bytes) of the message.
public size ( )
Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 /**
  * Obtain the mailbox size
  *
  * @param IMP_Mailbox $mbox   The mailbox to obtain the size of.
  * @param boolean $formatted  Whether to return a human readable value.
  *
  * @return mixed  Either the size of the mailbox (in bytes) or a formatted
  *                string with this information.
  */
 public function getSize(IMP_Mailbox $mbox, $formatted = true)
 {
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->size();
     try {
         $imp_imap = $mbox->imp_imap;
         $res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb(Horde_Imap_Client_Ids::ALL, true)));
         $size = 0;
         foreach ($res as $v) {
             $size += $v->getSize();
         }
         return $formatted ? sprintf(_("%.2fMB"), $size / (1024 * 1024)) : $size;
     } catch (IMP_Imap_Exception $e) {
         return 0;
     }
 }
Esempio n. 4
0
 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);
     //		}
 }
Esempio n. 5
0
 /**
  * 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']);
 }
Esempio n. 6
0
 /**
  * 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);
                         }
                     }
                     $v['preview'] = $preview_info[$uid]['IMPpreview'];
                     $v['previewcut'] = $preview_info[$uid]['IMPpreviewc'];
                 }
                 $overview[] = $v;
                 $mbox_ids[] = $uid;
             }
             $uids[$mbox] = $mbox_ids;
             if (!is_null($cache) && !empty($tostore)) {
                 $status = $imp_imap->status($mbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
                 $cache->set($mbox, $tostore, $status['uidvalidity']);
             }
         } catch (IMP_Imap_Exception $e) {
         }
     }
     return array('overview' => $overview, 'uids' => new IMP_Indices($uids));
 }
Esempio n. 7
0
 private function loadMessageBodies()
 {
     $headers = array();
     $fetch_query = new \Horde_Imap_Client_Fetch_Query();
     $fetch_query->envelope();
     $fetch_query->structure();
     $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));
     $fetch = $headers[$this->message_id];
     // 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->queryBodyPart($partId);
         }
     }
 }
Esempio n. 8
0
File: Imap.php Progetto: horde/horde
 /**
  * @depends testOptimizedSearches
  */
 public function testComplexFetch()
 {
     // Fetching message information from complex MIME message.
     $complex_fetch = new Horde_Imap_Client_Fetch_Query();
     $complex_fetch->fullText(array('length' => 100, 'peek' => true));
     // Header of entire message
     $complex_fetch->headerText(array('length' => 100, 'peek' => true));
     // Header of message/rfc822 part
     $complex_fetch->headerText(array('id' => 2, 'length' => 100, 'peek' => true));
     // Body text of entire message
     $complex_fetch->bodyText(array('length' => 100, 'peek' => true));
     // Body text of message/rfc822 part
     $complex_fetch->bodyText(array('id' => 2, 'length' => 100, 'peek' => true));
     // MIME Header of multipart/alternative part
     $complex_fetch->mimeHeader('1', array('length' => 100, 'peek' => true));
     // MIME Header of text/plain part embedded in message/rfc822 part
     $complex_fetch->mimeHeader('2.1', array('length' => 100, 'peek' => true));
     // Body text of multipart/alternative part
     $complex_fetch->bodyPart('1', array('length' => 100, 'peek' => true));
     // Body text of image/png part embedded in message/rfc822 part
     // Try to do server-side decoding, if available
     $complex_fetch->mimeHeader('2.2', array('decode' => true, 'length' => 100, 'peek' => true));
     // If supported, return decoded body part size
     $complex_fetch->bodyPartSize('2.2');
     // Select message-id header from base message header
     $complex_fetch->headers('headersearch1', array('message-id'), array('length' => 100, 'peek' => true));
     // Select everything but message-id header from message/rfc822 header
     $complex_fetch->headers('headersearch2', array('message-id'), array('id' => '2', 'length' => 100, 'notsearch' => true, 'peek' => true));
     $complex_fetch->structure();
     $complex_fetch->flags();
     $complex_fetch->imapDate();
     $complex_fetch->size();
     $complex_fetch->uid();
     if (self::$live->capability->query('CONDSTORE')) {
         $complex_fetch->modseq();
     }
     try {
         $res = self::$live->fetch(self::$test_mbox, $complex_fetch, array('ids' => new Horde_Imap_Client_Ids(3, true)));
     } catch (Horde_Imap_Client_Exception $e) {
         if ($e->getCode() === $e::MBOXNOMODSEQ) {
             $this->markTestSkipped('Mailbox does not support MODSEQ.');
         }
         throw $e;
     }
     $this->assertInstanceOf('Horde_Imap_Client_Fetch_Results', $res);
     $this->assertEquals(1, count($res));
     $this->assertEquals('Message-ID: <*****@*****.**>', trim($res[3]->getHeaders('headersearch1')));
     /* Return stream instead. */
     $this->assertInternalType('resource', $res[3]->getHeaders('headersearch1', Horde_Imap_Client_Data_Fetch::HEADER_STREAM));
     /* Parse headers instead. */
     $this->assertInstanceOf('Horde_Mime_Headers', $res[3]->getHeaders('headersearch1', Horde_Imap_Client_Data_Fetch::HEADER_PARSE));
 }
Esempio n. 9
0
 /**
  * Returns a list of messages, split into slices based on the total
  * message size.
  *
  * @param string $mbox                IMAP mailbox.
  * @param Horde_Imap_Client_Ids $ids  ID list.
  * @param integer $size               Maximum size of a slice.
  *
  * @return array  An array of Horde_Imap_Client_Ids objects.
  */
 public function getSlices($mbox, Horde_Imap_Client_Ids $ids, $size = 5242880)
 {
     $imp_imap = IMP_Mailbox::get($mbox)->imp_imap;
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->size();
     try {
         $res = $imp_imap->fetch($mbox, $query, array('ids' => $ids, 'nocache' => true));
     } catch (IMP_Imap_Exception $e) {
         return array();
     }
     $curr = $slices = array();
     $curr_size = 0;
     foreach ($res as $key => $val) {
         $curr_size += $val->getSize();
         if ($curr_size > $size) {
             $slices[] = $imp_imap->getIdsOb($curr, $ids->sequence);
             $curr = array();
         }
         $curr[] = $key;
     }
     $slices[] = $imp_imap->getIdsOb($curr, $ids->sequence);
     return $slices;
 }
Esempio n. 10
0
 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);
         }
     }
 }
Esempio n. 11
0
File: List.php Progetto: horde/horde
 /**
  * Build the array of message information.
  *
  * @param array $msgnum   An array of index numbers.
  *
  * @return array  An array with the following keys:
  * <pre>
  *   - 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 for non-envelope headers.
  *     - idx: (integer) Array index of this message.
  *     - mailbox: (string) The mailbox containing the message.
  *     - size: (integer) The size of the message in bytes.
  *     - uid: (string) The unique ID of the message.
  *   - uids: (IMP_Indices) An indices object.
  * </pre>
  */
 public function getMailboxArray($msgnum)
 {
     $this->_buildMailbox();
     $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();
     $fetch_query->headers('imp', array_merge(self::$headersUsed, IMP_Contents_Message::$headersUsed), array('cache' => true, 'peek' => true));
     /* Retrieve information from each mailbox. */
     foreach ($to_process as $mbox => $ids) {
         try {
             $imp_imap = IMP_Mailbox::get($mbox)->imp_imap;
             if ($imp_imap->config->atc_structure) {
                 $query = clone $fetch_query;
                 $query->structure();
             } else {
                 $query = $fetch_query;
             }
             $fetch_res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($ids)));
             $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(), 'structure' => $f->getStructure(), 'uid' => $uid);
                 $overview[] = $v;
                 $mbox_ids[] = $uid;
             }
             $uids[$mbox] = $mbox_ids;
         } catch (IMP_Imap_Exception $e) {
         }
     }
     return array('overview' => $overview, 'uids' => new IMP_Indices($uids));
 }
Esempio n. 12
0
 /**
  * @static
  * @param $user_id
  * @param $account_id
  * @param $folder_id
  * @param int $from
  * @param int $count
  * @return array
  */
 public static function getMessages($user_id, $account_id, $folder_id, $from = 0, $count = 20)
 {
     // get the account
     $account = App::getAccount($user_id, $account_id);
     if (!$account) {
         #TODO: i18n
         return array('error' => 'unknown account');
     }
     try {
         // connect to the imap server
         $conn = App::getImapConnection($account);
         $messages = array();
         //			$mb = new \Horde_Imap_Client_Mailbox($folder_id);
         $status = $conn->status($folder_id, \Horde_Imap_Client::STATUS_MESSAGES);
         $total = $status['messages'];
         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));
         // $list is an array of Horde_Imap_Client_Data_Fetch objects.
         $headers = $conn->fetch($folder_id, $fetch_query);
         foreach ($headers as $header) {
             $flags = array('SEEN' => True, 'ANSWERED' => False, 'FORWARDED' => False, 'DRAFT' => False, 'HAS_ATTACHMENTS' => True);
             //					\Horde_Imap_Client_Data_Fetch::HEADER_PARSE
             $f = $header->getFlags();
             $date = $header->getImapDate()->format('U');
             $id = $header->getUid();
             $e = $header->getEnvelope();
             $flags = array();
             $to = $e->to_decoded[0];
             $to = $to['personal'];
             //."<".$to['mailbox']."@".$to['host'].">";
             $from = $e->from_decoded[0];
             $from = $from['personal'];
             //."<".$from['mailbox']."@".$from['host'].">";
             $messages[] = array('id' => $id, 'from' => $from, 'to' => $to, 'subject' => $e->subject_decoded, 'date' => $date, 'size' => $header->getSize(), 'flags' => $flags);
         }
         return array('account_id' => $account_id, 'folder_id' => $folder_id, 'messages' => $messages);
     } catch (\Horde_Imap_Client_Exception $e) {
         return array('error' => $e->getMessage());
     }
 }