Horde_Imap_Client_Fetch_Query::headers PHP Method

headers() public method

This header search work only with the base RFC 2822 message or message/rfc822 parts.
public headers ( string $label, array $search, array $opts = [] )
$label string A unique label associated with this particular search. This is how the results are stored.
$search array The search string(s) (case-insensitive).
$opts array The following options are available: - cache: (boolean) If true, and 'peek' is also true, will cache the result of this call. DEFAULT: false - id: (string) The MIME ID to search. DEFAULT: The base message part - length: (integer) The length of the substring to return. DEFAULT: The entire text is returned. - notsearch: (boolean) Do a 'NOT' search on the headers. DEFAULT: false - peek: (boolean) If set, does not set the '\Seen' flag on the message. DEFAULT: The seen flag is set. - start: (integer) If a portion of the full text is desired to be returned, the starting position is identified here. DEFAULT: The entire text is returned.
    public function headers($label, $search, array $opts = array())
    {
        $this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = array_merge($opts, array('headers' => array_map('strval', $search)));
    }

Usage Example

Esempio n. 1
0
 /**
  * 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;
 }
All Usage Examples Of Horde_Imap_Client_Fetch_Query::headers