diff --git a/core/core.api.php b/core/core.api.php index cf3b3353ea69..27bc96d5c0f1 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -1947,9 +1947,10 @@ function hook_queue_info_alter(&$queues) { * Subject of the email to be sent. This must not contain any newline * characters, or the email may not be sent properly. * - 'body': - * An array of strings containing the message text. The message body is - * created by concatenating the individual array strings into a single text - * string using "\n\n" as a separator. + * An array of strings or objects that implement + * \Drupal\Component\Render\MarkupInterface containing the message text. The + * message body is created by concatenating the individual array strings + * into a single text string using "\n\n" as a separator. * - 'headers': * Associative array containing mail headers, such as From, Sender, * MIME-Version, Content-Type, etc. @@ -1998,7 +1999,9 @@ function hook_mail_alter(&$message) { * string when the hook is invoked. * - body: An array of lines containing the message to be sent. Drupal will * format the correct line endings for you. MailManagerInterface->mail() - * sets this to an empty array when the hook is invoked. + * sets this to an empty array when the hook is invoked. The array may + * contain either strings or objects implementing + * \Drupal\Component\Render\MarkupInterface. * - from: The address the message will be marked as being from, which is * set by MailManagerInterface->mail() to either a custom address or the * site-wide default email address when the hook is invoked. diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 63e1c4d8d048..7cba6b13e69f 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -135,7 +135,7 @@ function contact_mail($key, &$message, $params) { $message['subject'] .= t('[@form] @subject', $variables, $options); $message['body'][] = t("@sender-name (@sender-url) sent a message using the contact form at @form-url.", $variables, $options); $build = entity_view($contact_message, 'mail'); - $message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build); + $message['body'][] = \Drupal::service('renderer')->renderPlain($build); break; case 'page_autoreply': @@ -154,7 +154,7 @@ function contact_mail($key, &$message, $params) { $message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options); $message['body'][] = t("If you don't want to receive such emails, you can change your settings at @recipient-edit-url.", $variables, $options); $build = entity_view($contact_message, 'mail'); - $message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build); + $message['body'][] = \Drupal::service('renderer')->renderPlain($build); break; } }