首页 > 编程 > PHP > 正文

用php得到163的邮件信息

2019-11-17 04:26:59
字体:
来源:转载
供稿:网友

<?
$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."/r/n";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;

$command="pass ".$password."/r/n";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;

$command="stat/r/n";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;

$command="list/r/n";
fwrite($sock,$command);
while(true)
{
        $msg=fgets($sock);       
        echo $msg;
        if(PReg_match('/^/./',$msg))
                break;
}

$command="retr 1/r/n";
fwrite($sock,$command);
while(true)
{
        $msg=fgets($sock);
        echo $msg;
        if(preg_match('/^/.(/r/n)$/',$msg))
                break;
}

$command="quit/r/n";
fwrite($sock,$command);
$msg=fgets($sock);
echo $msg;
?>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表