protected function getMessages(Result $result)
    {
        $messages = array(
            'text' => '',
            'html' => '',
        );

        if ($result->hasMessages()) {
            $header = $this->t('mail_messages_header');
            $description = $this->t('mail_messages_desc');
            $descriptionHtml = $this->t('mail_messages_desc_html');
            $messagesText = $result->getMessages(Result::Format_FormattedText);
            $messagesHtml = $result->getMessages(Result::Format_Html);
            $messages = array(
                'text' => "\n$header\n\n$messagesText\n\n$description\n",
                'html' => "<details open><summary>$header</summary>$messagesHtml<p>$descriptionHtml</p></details>",
            );
        }
        return $messages;
    }