用php得到163的邮件信息

  •   2009-07-31/22:54
  • <?
    $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;
    ?>


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多