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 Link to comment https://forums.phpfreaks.com/topic/59848-imap_search/ 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? Link to comment https://forums.phpfreaks.com/topic/59848-imap_search/#findComment-299583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.