Get particular section structure of message
| From: | myhan | Date: | Sat, 06 Sep 2003 09:46:11 +0000 |
| Subject: | Get particular section structure of message | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-161854@lists.php.net to get a copy of this message | ||
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;
}