Commit 05c382ec authored by alexpott's avatar alexpott

Issue #2666160 by Berdir, tduong: contact_mail() casts rendered markup to string

parent 7fe7b049
......@@ -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.
......
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment