user_mail($key, &$message, $params)
Implements hook_mail().
File
- core/modules/user/user.module, line 910
- Enables the user registration and login system.
Code
function user_mail($key, &$message, $params) { $token_service = \Drupal::token(); $language_manager = \Drupal::languageManager(); $langcode = $message['langcode']; $variables = array('user' => $params['account']); $language = \Drupal::languageManager()->getLanguage($params['account']->getPreferredLangcode()); $original_language = $language_manager->getConfigOverrideLanguage(); $language_manager->setConfigOverrideLanguage($language); $mail_config = \Drupal::config('user.mail'); $token_options = ['langcode' => $langcode, 'callback' => 'user_mail_tokens', 'clear' => TRUE]; $message['subject'] .= PlainTextOutput::renderFromHtml($token_service->replace($mail_config->get($key . '.subject'), $variables, $token_options)); $message['body'][] = $token_service->replace($mail_config->get($key . '.body'), $variables, $token_options); $language_manager->setConfigOverrideLanguage($original_language); }
Please login to continue.