fetch() public méthode

Fetch message data (see RFC 3501 [6.4.5]).
public fetch ( mixed $mailbox, Horde_Imap_Client_Fetch_Query $query, array $options = [] ) : Horde_Imap_Client_Fetch_Results
$mailbox mixed The mailbox to search. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8).
$query Horde_Imap_Client_Fetch_Query Fetch query object.
$options array Additional options: - changedsince: (integer) Only return messages that have a mod-sequence larger than this value. This option requires the CONDSTORE IMAP extension (if not present, this value is ignored). Additionally, the mailbox must support mod-sequences or an exception will be thrown. If valid, this option implicity adds the mod-sequence fetch criteria to the fetch command. DEFAULT: Mod-sequence values are ignored. - exists: (boolean) Ensure that all ids returned exist on the server. If false, the list of ids returned in the results object is not guaranteed to reflect the current state of the remote mailbox. DEFAULT: false - ids: (Horde_Imap_Client_Ids) A list of messages to fetch data from. DEFAULT: All messages in $mailbox will be fetched. - nocache: (boolean) If true, will not cache the results (previously cached data will still be used to generate results) [since 2.8.0]. DEFAULT: false
Résultat Horde_Imap_Client_Fetch_Results A results object.
Exemple #1
0
 /**
  * Gets the raw text for one section of the message.
  *
  * @param integer $id     The ID of the MIME part.
  * @param array $options  Additional options:
  *   - decode: (boolean) Attempt to decode the bodypart on the remote
  *             server. If successful, sets self::$_lastBodyPartDecode to
  *             the content-type of the decoded data.
  *             DEFAULT: No
  *   - length: (integer) If set, only download this many bytes of the
  *             bodypart from the server.
  *             DEFAULT: All data is retrieved.
  *   - mimeheaders: (boolean) Include the MIME headers also?
  *                  DEFAULT: No
  *   - stream: (boolean) If true, return a stream.
  *             DEFAULT: No
  *
  * @return mixed  The text of the part or a stream resource if 'stream'
  *                is true.
  * @todo Simplify by removing 'mimeheaders' parameter (not used).
  */
 public function getBodyPart($id, $options)
 {
     $options = array_merge(array('decode' => false, 'mimeheaders' => false, 'stream' => false), $options);
     $this->_lastBodyPartDecode = null;
     $query = new Horde_Imap_Client_Fetch_Query();
     if (!isset($options['length']) || !empty($options['length'])) {
         $bodypart_params = array('decode' => true, 'peek' => true);
         if (isset($options['length'])) {
             $bodypart_params['start'] = 0;
             $bodypart_params['length'] = $options['length'];
         }
         $query->bodyPart($id, $bodypart_params);
     }
     if (!empty($options['mimeheaders'])) {
         $query->mimeHeader($id, array('peek' => true));
     }
     $fetch_res = $this->_imap->fetch($this->_mbox, $query, array('ids' => new Horde_Imap_Client_Ids(array($this->uid))));
     if (empty($options['mimeheaders'])) {
         $this->_lastBodyPartDecode = $fetch_res[$this->uid]->getBodyPartDecode($id);
         return $fetch_res[$this->uid]->getBodyPart($id, $options['stream']);
     } elseif (empty($options['stream'])) {
         return $fetch_res[$this->uid]->getMimeHeader($id) . $fetch_res[$this->uid]->getBodyPart($id);
     } else {
         $swrapper = new Horde_Support_CombineStream(array($fetch_res[$this->uid]->getMimeHeader($id, Horde_Imap_Client_Data_Fetch::HEADER_STREAM), $fetch_res[$this->uid]->getBodyPart($id, true)));
         return $swrapper->fopen();
     }
 }