function user_mail in Drupal 8
Same name and namespace in other branches
- 4 modules/user.module \user_mail()
- 6 modules/user/user.module \user_mail()
- 7 modules/user/user.module \user_mail()
- 9 core/modules/user/user.module \user_mail()
Implements hook_mail().
3 string references to 'user_mail'
- ContactPersonalTest::testSendPersonalContactMessage in core/
modules/ contact/ tests/ src/ Functional/ ContactPersonalTest.php - Tests that mails for contact messages are correctly sent.
- contact_mail in core/
modules/ contact/ contact.module - Implements hook_mail().
- MailHandlerTest::getSendMailMessages in core/
modules/ contact/ tests/ src/ Unit/ MailHandlerTest.php - Data provider for ::testSendMailMessages.
File
- core/
modules/ user/ user.module, line 1001 - 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 = [
'user' => $params['account'],
];
$language = $language_manager
->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);
}