日期:2014-01-05  浏览次数:20479 次

<?php
//by Alpha.Z
//05/21/2000

class myimap
{
        var    $username="";
        var    $userpwd="";
        var    $hostname="";
        var    $port=0;
        var    $connection=0;            //是否连接
        var    $state="DISCONNECTED";        //连接状态
        var    $greeting="";            
        var    $must_update=0;
        var    $inStream=0;

    Function open()
    {
        if ($this->port==110)
            $this->inStream=imap_open("{$this->hostname/pop3:110}inbox",$this->username,$this->userpwd);
        else
            $this->inStream=imap_open("{$this->hostname/imap:143}inbox",$this->username,$this->userpwd);

        if ($this->inStream)
        {
            echo "用户:$this->username 的信箱连接成功。<br>";
            return $inStream;
        }
        else
        {
            echo "用户:$this->username 的信箱连接失败。<br>";
            return 0;
        }
    }
    
    Function close()
    {
        if(imap_close($this->inStream))
        {
            echo "<hr>已经与服务器 $this->hostname 断开连接。";
            return 1;
        }
        else
        {
            echo "<hr>与服务器 $this->hostname 断开连接失败。";
            return 0;
        }
    }
    
    Function CheckMailbox()
    {
        $mboxinfo=@imap_mailboxmsginfo($this->inStream);
        //$mboxinfo=imap_check($this->inStream);
        if ($mboxinfo)
           &n