function user_mail

Implements hook_mail().

2 string references to 'user_mail'
contact_mail in drupal/core/modules/contact/contact.module
Implements hook_mail().
user_views_data in drupal/core/modules/user/user.views.inc
Implements hook_views_data().

File

drupal/core/modules/user/user.module, line 1700
Enables the user registration and login system.

Code

function user_mail($key, &$message, $params) {
  $token_service = Drupal::token();
  $langcode = $message['langcode'];
  $variables = array(
    'user' => $params['account'],
  );

  // Get configuration objects customized for the user specified in $params as
  // this user is not necessarily the same as the one triggering the mail. This
  // allows the configuration objects to be localized for the user's language if
  // the locale module is enabled.
  $user_config_context = config_context_enter('Drupal\\user\\UserConfigContext');
  $user_config_context
    ->setAccount($params['account']);
  $mail_config = config('user.mail');

  // We do not sanitize the token replacement, since the output of this
  // replacement is intended for an e-mail message, not a web browser.
  $token_options = array(
    'langcode' => $langcode,
    'callback' => 'user_mail_tokens',
    'sanitize' => FALSE,
    'clear' => TRUE,
  );
  $message['subject'] .= $token_service
    ->replace($mail_config
    ->get($key . '.subject'), $variables, $token_options);
  $message['body'][] = $token_service
    ->replace($mail_config
    ->get($key . '.body'), $variables, $token_options);

  // Return the previous config context.
  config_context_leave();
}