Hi,
I modified a little bit this very good function to make it work with this kind of email
test03.christophe-charron.org/publi ...
I hope it will be usefull and doesn't break anything else.
The initial function did not retreive the two parts (text and html) of the body.
This new one still doesn't get the file name in that case :
["content-type:"]=>string(92) "application/x-zip; name="=?UTF-8?Q?2007-07-19-Cr=C3=A9ation_fichier_adresses_courriel.ods?=""
when names are encoded...
Best regards,
Christophe Charron
function arrayFromEmailParts($parts,&$index){
foreach ($parts as $part) {
$tmp = explode(';',$part['Headers']['content-type:']);
$type = $tmp[0];
// multipart/alternative
if ($type == 'multipart/alternative') {
if (isset($ret)) {
$ret = array_merge($ret,arrayFromEmailParts($part['Parts'],$index));
} else {
$ret = arrayFromEmailParts($part['Parts'],$index);
}
} else {
if ($type == 'text/plain' OR $type == 'text/html') {
$ret[$index]['type'] = $type;
$ret[$index]['content'] = file_get_contents($part['BodyFile']);
} else {
$ret[$index]['type'] = $type;
$ret[$index]['file'] = $part['BodyFile'];
foreach($tmp as $data) {
if (strstr($data,'name')) {
$t = explode("=",$data);
$fileName = $t[1];
// outlook (and maybe others?) puts "" around the name, so remove if found
if(substr($fileName,0,1) == '"' AND substr($fileName,strlen($fileName)-1,1) == '"')
$fileName = substr($fileName,1,strlen($fileName)-2);
$ret[$index]['originalFileName'] = $fileName;
}
}
}
$index++;
}
}
return($ret);
}
Text function is here :
test03.christophe-charron.org/publi ...