<?
echo ini_get("default_socket_timeout");
set_time_limit(30);
echo "<pre>";
function sendres($fp,$command)
{
static $gat=7;
fputs($fp, "A000$gat $command\r\n");
// echo "A000$gat $command";
do
{
$df = fgets($fp);
echo $df;
flush();
}while(strpos($df,"A000$gat OK")===false);
echo "<br><br>";
flush();
$gat++;
}
function fetchuid($account, $password)
{
$retval = 0;
$fp = fsockopen('site or ip', 143);
if ($fp > 0)
{
$buf = fgets($fp, 1024);
echo $buf;
echo "<br><br>";
flush();
fputs($fp, "A0001 LOGIN $account $password\r\n");
$buf = fgets($fp, 1024);
echo $buf;
flush();
stream_set_timeout($fp, 10);
sendres($fp,"SELECT INBOX");
sendres($fp,"FETCH 1 full");
sendres($fp,"FETCH 1 body[text]");
fputs($fp, "A0008 LOGOUT\r\n");
$buf = fgets($fp);
fclose($fp);
}
echo "<br>";
echo $buf;// substr($retval,6,30);
}
fetchuid('user','pass');
?>