protected function appendToResponse(Response $response)
    {
        $existingContent = $response->getContent();
        $closeBodyPosition = strripos($existingContent, '</body>');
        $appendedContent = "
            <script>
                window.open('".route('mail-debug', ['file' => $this->debug->preview()])."','width=680,height=800,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
            </script>";

        if ($closeBodyPosition !== false) {
            $response->setContent(substr($existingContent, 0, $closeBodyPosition).$appendedContent.substr($existingContent, $closeBodyPosition));

            return;
        }

        $response->setContent($existingContent.$appendedContent);
    }