In these examples, $imap is assumed to be a previously configured/created Client object.
<?php $query = new Horde_Imap_Client_Search_Query(); $query->dateSearch( new Horde_Date($date_string), Horde_Imap_Client_Search_Query::DATE_SINCE ); // $list is an array, containing a single entry: 'match' $results = $imap->search('INBOX', $query); // A Horde_Imap_Client_Ids object containing the list of UIDs that matched the query. var_dump($results['match']); ?>
<?php $query = new Horde_Imap_Client_Fetch_Query(); $query->structure(); $uid = new Horde_Imap_Client_Ids($results['match']->ids[0]); $list = $imap->fetch('INBOX', $query, array( 'ids' => $uid )); $part = $list->first()->getStructure(); $id = $part->findBody(); $body = $part->getPart($id); $query2 = new Horde_Imap_Client_Fetch_Query(); $query2->bodyPart($id, array( 'decode' => true, 'peek' => true )); $list2 = $imap->fetch('INBOX', $query2, array( 'ids' => $uid )); $message2 = $list2->first(); $text = $message2->getBodyPart($id); if (!$message2->getBodyPartDecode($id)) { // Quick way to transfer decode contents $body->setContents($text); $text = $body->getContents(); } // $text now contains the plaintext body of the message. ?>