最新消息: 新版网站上线了!!!

PHP邮件接收类的改进

在《PHP接收邮件类(receivemail.class.php)下载 》中提到receivemail类的使用,针对部分留言反映通过该类接收的邮件出现乱码的问题,本文对邮件接收类receivemail类进行了改进,重点解决邮件乱码问题。

主要的改进如下:

1、新增了listMessages方法,用于列表邮件列表,且带有分页功能,更加方便调用

/**
 * listMessages - 获取邮件列表
 * @param $page - 第几页
 * @param $per_page - 每页显示多少封邮件
 * @param $sort - 邮件排序,如:array('by' => 'date', 'direction' => 'desc')
 * */
function listMessages($page = 1, $per_page = 25, $sort = null){}

2、新增了两个编码转换的方法,主要用于对邮件的相关信息进行编码转换。

调用方法如下:

include("receivemail.class.php");
$obj = receiveMail('abc@abc.com','xxxxxx','abc@abc.com','pop.abc.com','pop3','110', false);
$obj->connect();
$maillist = $obj->listMessages();
print_r($maillist);

运行结果大致如下:

Array
(
    [res] => Array
        (
         [0] => stdClass Object
          (
           [subject] => 解决PHP邮件接收类的乱码问题
           [from] => xxx
           [to] => abc
           [date] => Mon, 28 Jan 2013 14:23:06 +0800 (CST)
           [message_id] => <2afc51061915f95-00004.Richmail.00037000523146269922@xxx.com>
                    [size] => 42259
                    [uid] => 1
                    [msgno] => 1
                    [recent] => 1
                    [flagged] => 0
                    [answered] => 0
                    [deleted] => 0
                    [seen] => 0
                    [draft] => 0
                    [body] => 邮件内容
          )
        )
 [start] => 1
    [limit] => 25
    [sorting] => Array
        (
            [by] =>
            [direction] =>
        )

    [total] => 47
    [pages] => 2
)

附件下载:
http://img.kuitao8.com/uploads/2013/0915/20130915010312538.rar
2.68KB

转载请注明:谷谷点程序 » PHP邮件接收类的改进