beidlerj Posted July 13, 2007 Share Posted July 13, 2007 Hello, I am having trouble getting any results back from the imap_search function. I assume it has to do with getting the right query string. I am grabbing a string of keywords from an HTML form input box, and (trying to) search the IMAP inbox for messages which contain the $keywords string in either the BODY or the SUBJECT. Can anyone lend some help with the correct string to send to the server? I keep getting nothing back, meaning that the server doesn't understand the query. $link = imap_open($server, $UN, $PW) or die(imap_last_error()); $matches = imap_search($link, "BODY \"$keywords\" SUBJECT \"$keywords\""); if ($matches === false) { echo "Server didn't understand query.<p>"; echo imap_last_error(); } Thanks, Jeff Quote Link to comment Share on other sites More sharing options...
beidlerj Posted July 16, 2007 Author Share Posted July 16, 2007 If I only try this code: $matches = imap_search($link, "SUBJECT \"$keywords\""); I get an array of msg IDs that matched. However, when I try this code: $matches = imap_search($link, "BODY \"$keywords\""); ...then the function returns false. Is this a problem with the implementation, or is there some other "magic phrasing" I need to use, in order to search the body of messages for a keyword? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.