I don't have a suggestion, but a question.
I am working on pretty much the same thing you are it sounds like. I just started yesterday, and when I use the imap_open function; it's not connecting to the mailserver. I keep getting this error:
Warning: Couldn't open stream {IP of mailserver:143} in /home/dir/public_html/listMail.php on line 106
Warning: Unable to find stream pointer in /home/dir/public_html/listMail.php on line 107