protected function embedImages($email) {

        $html_embed = $email['body'];

        foreach ($email['attachments'] as $key => $attachment) {
            if (strtolower($attachment['disposition']) == 'inline' && !empty($attachment['reference'])){
                $file = $this->getAttachment($email['id'] , $key);

                $reference = str_replace(array("<", ">"), "", $attachment['reference']);
                $img_embed = "data:image/" . strtolower($file['type']) . ";base64," . base64_encode($file['content']);

                $html_embed = str_replace("cid:" . $reference, $img_embed, $html_embed);
            }
        }
        return $html_embed;
    }