.... +$arrLocalNames = array(); foreach ($message->attachments as $part) { ....
.... $disp_name = $this->_convert_filename($filename); +if (!empty($disp_name)) +{ + // We have to make sure that there aren't two of the same local names. + // Otherwise, one file will override the other and we will be missing the file. + while($arrLocalNames[$disp_name] > 0) + { + $arrPathInfo = pathinfo($disp_name); + $intNext = $arrLocalNames[$disp_name]++; + $disp_name = $arrPathInfo['filename'] . "_" . $intNext . "." . $arrPathInfo['extension']; + } + // Add to the count. + $arrLocalNames[$disp_name]++; +} $tmpfn = tempnam($temp_dir, 'zipattach'); ....