您的位置:首页技术文章
文章详情页

用php得到163的邮件信息

【字号: 日期:2024-02-17 09:08:19浏览:2作者:猪猪

<?$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;?>

标签: PHP