avoid fatal error on getContents when no part is found

This commit is contained in:
Klaus Leithoff 2014-10-02 08:25:34 +00:00
parent 204d73ab52
commit ae1e4707de

View File

@ -5025,11 +5025,16 @@ class emailadmin_imapbase
}
$ext = mime_magic::mime2ext($structure_mime);
if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext;
//error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename);
if (!$part)
{
error_log(__METHOD__.__LINE__.'Error: Could not fetch attachment for:'." Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr in $_folder:".array2string(function_backtrace()));
error_log(__METHOD__.__LINE__.'# Fetched StructureMime:'.$structure_mime.' with Filename:'.$filename);
}
$attachmentData = array(
'type' => $structure_mime,
'filename' => $filename,
'attachment' => $part->getContents(array('stream'=>$_stream))
//'attachment' => $part->getContents(array('stream'=>$_stream))
'attachment' => ($part?$part->getContents(array('stream'=>$_stream)):'Error: Could not fetch attachment for:'." Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr in $_folder:".array2string(function_backtrace()))
);
// try guessing the mimetype, if we get the application/octet-stream