日期:2011-01-02  浏览次数:20485 次

myimap类,读取邮件
<?php
//////////////////////////////////////////////
//Origin by Alpha.Z (5/21/2000)
//Modified By Belltree <belltree@163.com> (11/01/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;
var $num_msg_parts = 0;
var $attach;
var $num_of_attach = 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.":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 DeleteMail($msg_no){
if (@imap_delete($this->inStream,$msg_no))
return true;
else
return false;
}

function ExpungeMail(){
if (@imap_expunge($this->inStream))
return true;
else
return false;
}

function CheckMailbox($page_size,$page)
{
$mboxinfo=@imap_mailboxmsginfo($this->inStream);
//$mboxinfo=imap_check($this->inStream);
if ($mboxinfo)
if ($mboxinfo->Nmsgs>0)
{
//echo "您邮箱:".$mboxinfo->Mailbox."<br>";
echo $this->username."@wells.com的收件箱里共有邮件数:".$mboxinfo->Nmsgs."<br>\n";
echo "未读邮件数:".$mboxinfo->Unread." ";
echo "新邮件数:".$mboxinfo->Recent." ";
echo "总共占用空间:".$mboxinfo->Size."字节<br>\n";
$last_page = ceil($mboxinfo->Nmsgs/$page_size);
$cur_page = $page +1;
$num_page = $last_page;
echo "第&