--- pipe.php.orig 2008-09-01 11:01:07.000000000 +0200 +++ pipe.php 2008-09-01 10:59:01.000000000 +0200 @@ -104,13 +104,21 @@ //Ticket created...save attachments if enabled. $struct=$parser->getStruct(); if($struct && $struct->parts && $cfg->allowEmailAttachments()) { - for($i = 0; $i < count($struct->parts); $i++) { - $part=$struct->parts[$i]; - if($part->disposition - && (!strcasecmp($part->disposition,'attachment') || !strcasecmp($part->disposition,'inline') || !strcasecmp($part->ctype_primary,'image'))){ + $parts = $struct->parts; + getparts($parts, $cfg, $ticket, $msgid); +} + +//Function has to be recursive, cause a mail can have multiple nested parts +//There is rly no need to check the depth of the recursion (how many parts will be there dude?) +function getparts($parts, $cfg, $ticket, $msgid) { + for($i = 0; $i < count($parts); $i++) { + $part = $parts[$i]; + if($part->parts) { getparts($part->parts, $cfg, $ticket, $msgid); } + if($part->disposition + && (!strcasecmp($part->disposition, 'attachment') || !strcasecmp($part->disposition, 'inline') || !strcasecmp($part->ctype_primary, 'image'))) { $filename=$part->d_parameters['filename']; if($filename && $cfg->canUploadFileType($filename)) { - $ticket->saveAttachment($filename,$part->body,$msgid,'M'); + $ticket->saveAttachment($filename, $part->body, $msgid, 'M'); } } }