I am using hook_mail_alter to modify the email that the user gets when an administrator creates an account. What I am trying to do is create a link in the email body, the link gets created but it adds a [1] to the link text and after the email text is done. There is the [1] again with the actual link. Is there anyway to actually have the link created in the text instead of having it render at the end? Here is my code:
function my_module_mail_alter(&$message) {
if ($message['id'] = 'user_register_admin_created') {
$url = Url::fromUri('https://www.google.com');
$external_link = \Drupal::l(t('Google'), $url);
$message['body'][] = t("Go to: ");
$message['body'][] = $external_link;
}
}