tags:

views:

28

answers:

2

It works on XAMPP but not on the host that serves my website (linux server). I do not see any error messages and the script just times out.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
   <title>Email Parser</title>
</head>

<body>
<?php

echo "Hello World";

$hostname = '{imap.gmail.com:993/imap/ssl}Inbox';
$username = '[email protected]'; //Replaced with actual user name and 
$password = 'abc';           //password in the script

$mbox = imap_open($hostname, $username, $password) or die("can't connect: " . imap_last_error());
echo "+++++ <br>";
$MC = imap_check($mbox);

echo "***** <br>";
echo $MC->Nmsgs;

?>
</body>
</html>
A: 

Probably your host hasn't got the php_imap extention enabled

test that by doing:

var_dump(function_exists('imap_open')) ;

For your script to work the above should display 'bool(true)'. If bool(false) you've found the culprit.

Amelia
The output shows bool(true). Thanks for the suggestion though.
smitten
A: 

Can you reach that host/port using other means from the server? Even though you can't do the SSL stuff by hand, you could try telnet (telnet imap.gmail.com 993) from the command line and see if that gets a connection. Possibly your server's firewalled off somehow.

Marc B
Thanks a lot! That was the problem. I contacted my hosting company to open the port for me and it is working now :)
smitten