function SystemHooks::mail

Same name and namespace in other branches
  1. 11.x core/modules/system/src/Hook/SystemHooks.php \Drupal\system\Hook\SystemHooks::mail()

Implements hook_mail().

Attributes

#[Hook('mail')]

File

core/modules/system/src/Hook/SystemHooks.php, line 315

Class

SystemHooks
Hook implementations for system.

Namespace

Drupal\system\Hook

Code

public function mail($key, &$message, $params) : void {
  $token_service = \Drupal::token();
  $context = $params['context'];
  $subject = PlainTextOutput::renderFromHtml($token_service->replace($context['subject'], $context));
  $body = $token_service->replace($context['message'], $context);
  $message['subject'] .= str_replace([
    "\r",
    "\n",
  ], '', $subject);
  $message['body'][] = $body;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.