imap_searchDescriptionSimilar to imap_scanmailbox() except this function searchs only the current mailbox and the search criteria is able to be specified. The search criteria specified by searchtext is deliminated by spaces and if multiworded arguments are required, they must be enclosed in quote marks. Prepended to user defined search strings in searchtext is an argument specifying which messages and message parts are to be search. These are:
The only possible value for flags is SE_UID which returns the UID of the message rather then the message ID. WarningThis list may not be accurate due to client implementations. For a canonical list, see section 6.4.4 of RFC2060 ExampleExample 619. Search for all messages with 'password' in the subject <?php $imap = imap_open("{localhost}INBOX","graeme","inferno"); // search only in the subvject for the string 'password' $boxes = imap_search($imap, "SUBJECT password"); for ($i=0; $i<count($boxes); $i++) { echo "Match found in number: $boxes[$i]<BR>\n"; } // search again but return the UID $boxes = imap_search($imap, "SUBJECT password", SE_UID); for ($i=0; $i<count($boxes); $i++) { echo "Match found in UID: $boxes[$i]<BR>\n"; } imap_close($imap); ?> Output: Match found in number: 2 Message found in UID: 8
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing
(Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch).
This material may be distributed only subject to the terms and conditions set forth
in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
The authors of this book have elected not to choose any options under the OPL. This online book was obtained
from http://www.fooassociates.com/phpfer/
and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4
for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All
persons and entities shall have neither liability nor responsibility to any person or entity with respect to
any loss or damage arising from the information contained in this book.
|