-
PHP接收邮件类receivemail.class.php下载
资源介绍
receivemail是一个专门用来接收邮件的PHP类,支持POP3和IMAP等邮件协议。
可以接收邮件及邮件附件。
include("receivemail.class.php");
02
// 创建一个 reciveMail 对象
03
$obj = new receiveMail('abc@abc.com','xxxxxx','abc@abc.com','pop.abc.com','pop3','110',false);
04
// 连接到邮件服务器
05
$obj->connect(); //If connection fails give error message and exit
06
// 读取未读邮件数
07
$tot = $obj->getTotalMails(); //Total Mails in Inbox Return integer value
08
09
echo "收到$tot封邮件::
"; 10 for($i = $tot; $i > 0; $i--) 11 { 12 $head = $obj->getHeaders($i); // 读取获取邮件头信息,返回数组 **数组键值为 (subject,to,toOth,toNameOth,from,fromName) 13 echo "主题 :: ".$head['subject']."
"; 14 echo "收件人 :: ".$head['to']."
"; 15 echo "抄送 :: ".$head['toOth']."
"; 16 echo "发件人 :: ".$head['from']."
"; 17 echo "发件人名称 :: ".$head['fromName']."
"; 18 echo "
"; 19 echo "
*******************************************************************************************
"; 20 echo $obj->getBody($i); // 邮件正文 21 $str = $obj->GetAttach($i,"./"); // 获取邮件附件,返回的文件名以逗号隔开。 例如. (mailid, Path to store file) 22 $ar = explode(",",$str); 23 foreach($ar as $key=>$value) 24 echo ($value == "") ? "" : "Atteched File :: " . $value . "
"; 25 echo "
------------------------------------------------------------------------------------------
"; 26 //$obj->deleteMails($i); // Delete Mail from Mail box 27 } 28 $obj->close_mailbox(); //Close Mail Box
"; 10 for($i = $tot; $i > 0; $i--) 11 { 12 $head = $obj->getHeaders($i); // 读取获取邮件头信息,返回数组 **数组键值为 (subject,to,toOth,toNameOth,from,fromName) 13 echo "主题 :: ".$head['subject']."
"; 14 echo "收件人 :: ".$head['to']."
"; 15 echo "抄送 :: ".$head['toOth']."
"; 16 echo "发件人 :: ".$head['from']."
"; 17 echo "发件人名称 :: ".$head['fromName']."
"; 18 echo "
"; 19 echo "
*******************************************************************************************
"; 20 echo $obj->getBody($i); // 邮件正文 21 $str = $obj->GetAttach($i,"./"); // 获取邮件附件,返回的文件名以逗号隔开。 例如. (mailid, Path to store file) 22 $ar = explode(",",$str); 23 foreach($ar as $key=>$value) 24 echo ($value == "") ? "" : "Atteched File :: " . $value . "
"; 25 echo "
------------------------------------------------------------------------------------------
"; 26 //$obj->deleteMails($i); // Delete Mail from Mail box 27 } 28 $obj->close_mailbox(); //Close Mail Box
- 上一篇: php-email类
- 下一篇: Smtp.class.php