foreach ($mail->parts as $id => $part) {
$fname = part_filename($part);
if ($fname) {
logs("Escribiendo archivo '$fname' [enc={$part->encoding}]", DEBUG);
$body = imap_fetchbody($mbox, $msgid, $id + 1);
foreach ($mail->parts as $id => $part) {
$fname = part_filename($part);
if ($fname) {
logs("Escribiendo archivo '$fname' [enc={$part->encoding}]", DEBUG);
$body = imap_fetchbody($mbox, $msgid, $id + 1);