function user_mail in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/user.module \user_mail()
Implements hook_mail().
3 string references to 'user_mail'
- ContactPersonalTest::testSendPersonalContactMessage in core/
modules/ contact/ src/ Tests/ 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 908 - 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);
}