The previous post contains a copy/paste error and a little added complexity. The first function should look like this:
<?php
function create_part_array($struct) {
if (sizeof($struct->parts) > 0) { // There some sub parts
foreach ($struct->parts as $count => $part) {
add_part_to_array($part, ($count+1), $part_array);
}
}else{ // Email does not have a seperate mime attachment for text
$part_array[] = array('part_number' => '1', 'part_object' => $struct);
}
return $part_array;
}
?>