I make a function to fetch the structure of a particulat section of a
message,
and I test it with some special mails and it works well.
But for I am not so familiar with mime-types, I need more suggest and help.

    function getCurrentStruct($pi_msgid, $ps_part=1)
    {
        //$o_struct = $this->getStructure($pi_msgid);
        $o_struct = imap_fetchstructure($mbox, $pi_msgid);
        //$ps_part is a string like "4.3.3"
        if (!array_key_exists("parts", get_object_vars($o_struct))) {
            //$this->pushError("No such part");
            //call imap_errors() and return the last error
            return new PEAR_Error($this->getError());
        }
        foreach (explode(".", $ps_part) as $i) {
            if (!array_key_exists("parts", get_object_vars($o_struct)) ||
!is_array($o_struct->parts)) {
                return new PEAR_Error("No such part");
            }
            $a_tmp = $o_struct->parts;
            if ($a_tmp[0]->type == 1) { // &&
(strtoupper($a_tmp[0]->subtype)=="MIXED") {
                $a_tmp = $a_tmp[0]->parts;
            }
            $o_struct = $a_tmp[$i-1];
        }
        return $o_struct;
    }

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to