imap_open, PHP 5.2.5, and Gmail

Hey guys. Got a favor to ask. I am a newbie to PHP and picked up a very small freelance to help me learn(which I do best by putting myself in the 'middle of it') The script sends an email and then logs into the account and verifies that it arrived. Here's my issue, a couple weeks ago I created a similar script and it was running fine on my hosting company. Come to find out today that they have upgraded to 5.2.5 and my imap_open to GMail is now failing every time. So, long story short, could somewhere look at this code and see if I have any GLARING errors that would be causing this to fail?

 

// Build emailID and send email
$emailID = generateID($parameters["idLength"]);
$emailDateTime = date("Y-m-d, H:i");
$emailSubject = $emailDateTime."|".$emailID;
mail ($parameters["emailTo"], $emailSubject , "" , "From:".$parameters["emailFrom"]."\r\n");

// Capture time email was sent
$emailSentTime = time();

// Log into email server and check for arrival of email until it is found
// or delaySeconds is exceeded

$ms = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX",$parameters["emailUsername"] ,$parameters["emailPassword"] ) or die("can't connect: " . imap_last_error());
$emailArrived = FALSE;
while (((time() - $emailSentTime) < $parameters["delaySeconds"]) && ($emailArrived == FALSE)) {
$headers = imap_headers($ms);
for ($x=0;$x<=(count($headers)-1);$x++){
if (ereg($emailSubject, $headers[$x])) {
$emailArrived = TRUE;
$emailArrivalTime = time();
break;
}
}
}