I've experienced some problems with imap_search function when I set SE_UID flag in case of UNSEEN it return false by some reason.
I tried 'ALL' filter criteria and it works fine in all cases:
$emails = imap_search($inbox, 'ALL', SE_UID); // return data
$emails = imap_search($inbox, 'ALL'); // return data
but when I set 'UNSEEN' filter criteria it start returns false in case when SE_UID flag set.
$emails = imap_search($inbox, 'UNSEEN'); // return data
$emails = imap_search($inbox, 'UNSEEN', SE_UID); //return false - why?