Using sender name and removing HTML entity encoding in Swiftmailer I have swiftmailer installed on a Drupal 8 installation. I am using a hook_mail() function to edit the message params as follows:

function mymodule_mail($key, &amp;$message, $params) {
    $options = array(
        'langcode' =&gt; $message['langcode'],
    );
    switch ($key) {
        case 'support_form':
            $message['files'] = $params['files'];
        case 'submit_to_admin':
        case 'submit_to_user':
            $message['from'] = array(\Drupal::config('system.site')-&gt;get('mail') =&gt; 'site admin name');
            $message['subject'] = t('@title', array('@title' =&gt; $params['title']), $options);
            $message['body'][] = Html::escape($params['message']);
            break;
    }
}


I am sending the e-mail like this:

$mailManager = \Drupal::service('plugin.manager.mail');
$module = 'mymodule';
$key = 'support_form';
$params['message'] = $message; //defined elsewhere
$params['files'] = $attachments; //defined elsewhere
$params['title'] = $title; //defined elsewhere
$langcode = \Drupal::currentUser()-&gt;getPreferredLangcode();
$send = true;
$result = $mailManager-&gt;mail($module, $key, $to, $langcode, $params, NULL, $send);


The e-mail is sending fine, including attachments (so I know Swiftmailer must be working), but when I receive the e-mail the sender is listed as just the e-mail address and not as "site admin name".

Additionally, any &amp; symbol in the body is showing up as &amp;amp;amp;

My swiftmailer install is configured according to this guide.

Is there a setting or code piece I am missing that is making this happen?
I had the same issue and did the following to solve the issue with the entities.

$text = $message['body'];
$message['body'] = array_map(function ($text) {
  return Markup::create($text);
}, $text);


This will convert the body and will not display any entites anymore.