phpimap

imap_search and FROM criteria


Is it possible to have multiple FROM criterias declared?

I've tried:

$emails = imap_search($imap, 'FROM "test@stackoverflow.com" FROM2 "test2@stackoverflow.com"');

$emails = imap_search($imap, 'FROM "test@stackoverflow.com,test2@stackoverflow.com"');

$emails = imap_search($imap, 'FROM "test@stackoverflow.com" OR FROM "test2@stackoverflow.com"');

None of those works. Anyone knows a solution?


Solution

  • Never used imap before, but you could try something like this?

    $from = array("test@stackoverflow.com", "test2@stackoverflow.com");
    $emails = array();
    
    foreach($from as $search){
        $emails[] = imap_search($imap, 'FROM "'.$search.'"');
    }