protected function addContentToMailerInternal($message, $template, $data, $plainOnly = false)
    {
        /*
         * Start twig transaction
         */
        $this->startTwig();

        /*
         * Inject global view variables
         */
        $globalVars = ViewHelper::getGlobalVars();
        if (!empty($globalVars)) {
            $data = (array) $data + $globalVars;
        }

        /*
         * Subject
         */
        $swiftMessage = $message->getSwiftMessage();

        if (empty($swiftMessage->getSubject())) {
            $message->subject(Twig::parse($template->subject, $data));
        }

        $data += [
            'subject' => $swiftMessage->getSubject()
        ];

        if (!$plainOnly) {
            /*
             * HTML contents
             */
            $html = $this->renderTemplate($template, $data);

            $message->setBody($html, 'text/html');
        }

        /*
         * Text contents
         */
        $text = $this->renderTextTemplate($template, $data);

        $message->addPart($text, 'text/plain');

        /*
         * End twig transaction
         */
        $this->stopTwig();
    }