PHP接收邮件类(receivemail.class.php)下载

近日在网上看很多人问到PHP接收邮件的类,因为手上正好有这个类,所以放上去供大家下载。

receivemail是一个专门用来接收邮件的PHP类,支持POP3和IMAP等邮件协议。

可以接收邮件及邮件附件。

使用方法如下:

include("receivemail.class.php");
// 创建一个 reciveMail 对象
$obj = new receiveMail('abc@abc.com','xxxxxx','abc@abc.com','pop.abc.com','pop3','110',false);
// 连接到邮件服务器
$obj->connect();         //If connection fails give error message and exit
// 读取未读邮件数
$tot = $obj->getTotalMails(); //Total Mails in Inbox Return integer value

echo "收到$tot封邮件::<br>";
for($i = $tot; $i > 0; $i--)
{
	$head = $obj->getHeaders($i);  // 读取获取邮件头信息,返回数组 **数组键值为 (subject,to,toOth,toNameOth,from,fromName)
	echo "主题 :: ".$head['subject']."<br>";
	echo "收件人 :: ".$head['to']."<br>";
	echo "抄送 :: ".$head['toOth']."<br>";
	echo "发件人 :: ".$head['from']."<br>";
	echo "发件人名称 :: ".$head['fromName']."<br>";
	echo "<br><br>";
	echo "<br>*******************************************************************************************<br>";
	echo $obj->getBody($i);  // 邮件正文
	$str = $obj->GetAttach($i,"./"); // 获取邮件附件,返回的文件名以逗号隔开。 例如. (mailid, Path to store file)
	$ar = explode(",",$str);
	foreach($ar as $key=>$value)
		echo ($value == "") ? "" : "Atteched File :: " . $value . "<br>";
	echo "<br>------------------------------------------------------------------------------------------<br>";
	//$obj->deleteMails($i); // Delete Mail from Mail box
}
$obj->close_mailbox();   //Close Mail Box

reciveMail类的构造函数如下:

function reciveMail($username,$password,$EmailAddress,$mailserver='localhost',$servertype='pop',$port='110')
  1. 参数说明:
     $username        : User name off the mail box
     $password         : Password of mailbox
     $emailAddress   :Email address of that mailbox some time the uname and email address are identical
     $mailserver        :Ip or name of the POP or IMAP mail server
     $servertype        :if this server is imap or pop default is pop
     $port                  :Server port for pop or imap Default is 110 for pop and 143 for imap

以上就是有关PHP接收邮件类的介绍,receivemail.class.php这个类可以下载本文附件。

附件包含以下文件:

/example.php
/ReadMe.txt
/receivemail.class.php

同时欢迎大家留言。

receivemail.class.php需要imap模块支持。php_imap.dll可以通过附件php_imap.dll.rar下载。

附件下载:
附件下载

转载于:https://my.oschina.net/idufei/blog/40150

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值