private function addLinkToResponse($response, $previewPath)
    {
        if (app()->runningInConsole()) {
            return;
        }

        $content = $response->getContent();

        $linkHTML = "<div id='MailPreviewDriverBox' style='
            position:absolute;
            top:0;
            z-index:99999;
            background:#fff;
            border:solid 1px #ccc;
            padding: 15px;
            '>
        An email was just sent: <a href='".url('/themsaid/mail-preview?path='.$previewPath)."'>Preview Sent Email</a>
        </div>";

        $timeout = intval(config('mailpreview.popup_timeout', 8000));

        if ($timeout > 0) {
            $linkHTML .= "<script type=\"text/javascript\">";

            $linkHTML .= "setTimeout(function(){
            document.body.removeChild(document.getElementById('MailPreviewDriverBox'));
            }, " . $timeout . ");";

            $linkHTML .= "</script>";
        }


        $bodyPosition = strripos($content, '</body>');

        if (false !== $bodyPosition) {
            $content = substr($content, 0, $bodyPosition).$linkHTML.substr($content, $bodyPosition);
        }

        $response->setContent($content);
    }