Heim > Artikel > Backend-Entwicklung > 用php得到163的邮件信息_PHP教程
if(!($sock=fsockopen(gethostbyname($host),$port,$errno,$errstr))) $msg=fgets($sock); $command="user ".$user."
"; $command="pass ".$password."
"; $command="stat
"; $command="list
"; $command="retr 1
"; $command="quit
";
$host=pop.163.com;
$port=110;
$user=******;
$password=******;
exit($errno.: .$errstr);
set_socket_blocking($sock,true);
echo $msg;
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
fwrite($sock,$command);
while(true)
{
$msg=fgets($sock);
echo $msg;
if(preg_match(/^./,$msg))
break;
}
fwrite($sock,$command);
while(true)
{
$msg=fgets($sock);
echo $msg;
if(preg_match(/^.(
)$/,$msg))
break;
}
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
?>