How can I use the Conditional OR to search emails with imap_search - PHP IMAP library

后端 未结 2 1811
醉酒成梦
醉酒成梦 2021-01-24 00:06

I need to use an OR statement in an imap_search() command.

I found that a condition OR is not supported in this library. Imap_search Bug Report Link There has to be a w

2条回答
  •  渐次进展
    2021-01-24 00:20

    or use instead an array_merge to join the results in a single array:

    //search codes: 1 -> FROM, 2 -> SUBJECT
    array_push($filtri, array(1,"no-reply@accounts.google.com"));
    array_push($filtri, array(1,"Tophost"));
    array_push($filtri, array(2,"promemoria"));
    
    $yesterday = date("Y-m-d", strtotime ("-1 days"));
    
    foreach($filtri as $filtro){
        if ($filtro[0] == 1) $addFiltri = ' FROM "'.$filtro[1].'" ';
        if ($filtro[0] == 2) $addFiltri = ' SUBJECT "'.$filtro[1].'" ';
        $temp = imap_search($inbox,'SINCE "'.$yesterday.'" '.$addFiltri);
        $emails = array_merge($emails , $temp); 
    
    }
    

提交回复
热议问题