Search code examples
phpimap

imap_search and FROM criteria


Is it possible to have multiple FROM criterias declared?

I've tried:

$emails = imap_search($imap, 'FROM "[email protected]" FROM2 "[email protected]"');

$emails = imap_search($imap, 'FROM "[email protected],[email protected]"');

$emails = imap_search($imap, 'FROM "[email protected]" OR FROM "[email protected]"');

None of those works. Anyone knows a solution?


Solution

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

    $from = array("[email protected]", "[email protected]");
    $emails = array();
    
    foreach($from as $search){
        $emails[] = imap_search($imap, 'FROM "'.$search.'"');
    }