Hi,
be aware, that imap_search() does NOT (as you may exspect) return an empty array, if nothing was found!
As the manual says, it returns FALSE.
Do not test the result like "count($array)" as I did.
This gives you 1 for an empty result. Took me an hour to found out why :-( RTFM