note 42621 deleted from function.imap-fetchbody by vincent
| From: | vincent@php.net | Date: | Mon, 24 May 2004 16:41:35 +0000 |
| Subject: | note 42621 deleted from function.imap-fetchbody by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70029@lists.php.net to get a copy of this message | ||
Note Submitter: Sito
----
The above code(great!) works with multipart messages, but with non-multipart ones, because
'foreach' receives an invalid argument. I've made a little fix:
function read_all_parts($uid){
global $mime,$ret_info,$enc;
$mime =
array("text","multipart","message","application","audio",
"image","video","other","unknow");
$enc = array("7BIT","8BIT","BINARY","BASE64",
"QUOTED-PRINTABLE","OTHER");
$struct = imap_fetchstructure( $this -> Link, $uid );
$ret_info = array();
function scan($struct,$subkey){
global $mime,$enc,$ret_info;
if($struct->parts){
foreach($struct as $key => $value){
if($subkey!=0){
$pid = $subkey.".".($key+1); }
else { $pid = ($key+1); }
$ret_info[]['pid'] = $pid;
$ret_info[key($ret_info)]['type'] = $mime["$value->type"];
$ret_info[key($ret_info)]['encoding'] = $enc["$value->encoding"];
next($ret_info);
if(($value->parts)!= null) {scan($value->parts,$pid); }
}
}
else
{
$ret_info[]['pid']=1;
}
}
scan($struct->parts,0);
return $ret_info;
}