lib/ImapHelper.php
public function getAttachments(Message $message)
    {
        $attachments = null;

        // Only multi-part will have attachments
        if ($message->isMultipart()) {
            if ($message->countParts() > 1) {

                $partCount = $message->countParts();
                for ($i = 0; $i < $partCount; $i++) {
                    $part = $message->getPart($i + 1);

                    // Check for headers, to avoid exceptions
                    if ($part->getHeaders() !== null) {
                        // Getting disposition
                        $disposition = null;
                        try {
                            $disposition = $part->getHeaderField('Content-Disposition');
                        } catch (\Exception $e) {
                            // Zend throws an Exception, if headerField does not exist
                        }

                        if ($disposition == 'attachment') {
                            $content = quoted_printable_decode($part->getContent());

                            // Encoding?
                            try {
                                $transferEncoding = $part->getHeaderField('Content-Transfer-Encoding');

                                if ($transferEncoding == 'base64') {
                                    $content = base64_decode($content);
                                }
                            } catch (\Exception $e) {
                                // Zend throws an Exception, if headerField does not exist
                            }

                            $attachments[] = array(
                                'mime'     => $part->getHeaderField('Content-Type'),
                                'filename' => $part->getHeaderField('Content-Disposition', 'filename'),
                                'content'  => $content
                            );
                        }
                    }
                }
            }
        }

        return $attachments;
    }
public function getAttachments(Message $message)
    {
        $attachments = null;

        // Only multi-part will have attachments
        if ($message->isMultipart()) {
            if ($message->countParts() > 1) {

                $partCount = $message->countParts();
                for ($i = 0; $i < $partCount; $i++) {
                    $part = $message->getPart($i + 1);

                    // Check for headers, to avoid exceptions
                    if ($part->getHeaders() !== null) {
                        // Getting disposition
                        $disposition = null;
                        try {
                            $disposition = $part->getHeaderField('Content-Disposition');
                        } catch (\Exception $e) {
                            // Zend throws an Exception, if headerField does not exist
                        }

                        if ($disposition == 'attachment') {
                            $content = quoted_printable_decode($part->getContent());

                            // Encoding?
                            try {
                                $transferEncoding = $part->getHeaderField('Content-Transfer-Encoding');

                                if ($transferEncoding == 'base64') {
                                    $content = base64_decode($content);
                                }
                            } catch (\Exception $e) {
                                // Zend throws an Exception, if headerField does not exist
                            }

                            $attachments[] = array(
                                'mime'     => $part->getHeaderField('Content-Type'),
                                'filename' => $part->getHeaderField('Content-Disposition', 'filename'),
                                'content'  => $content
                            );
                        }
                    }
                }
            }
        }

        return $attachments;
    }
@param Message $message

@return array|null