<?
$host='pop.163.com';
$port=110;
$user='******';
$password='******';
if(!($sock=fsockopen(gethostbyname($host),$port,$errno,$errstr)))
exit($errno.': '.$errstr);
set_socket_blocking($sock,true);
$msg=fgets($sock);
echo $msg;
$command="user ".$user."rn";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
$command="pass ".$password."rn";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
$command="statrn";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
$command="listrn";
fwrite($sock,$command);
while(true)
{
$msg=fgets($sock)
echo $msg;
if(preg_match('/^./',$msg))
break;
}
$command="retr 1rn";
fwrite($sock,$command);
while(true)
{
$msg=fgets($sock);
echo $msg;
if(preg_match('/^.(rn)$/',$msg))
break;
}
$command="quitrn";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
?>
标签: