function login_history_mail in Login History 7
Implements hook_mail().
File
- ./
login_history.module, line 222 - The login history module.
Code
function login_history_mail($key, &$message, $params) {
if ('login_history_new_device' == $key) {
$language = $message['language'];
$langcode = isset($language->language) ? $language->language : NULL;
$subject = t('New device login for [user:name] at [site:name]', array(), array(
'langcode' => $langcode,
));
$body = t("[user:name], a new device or browser logged in to your [site:name] account:\nWhen: [current-date:short]\nIP Address: @hostname\nDevice & Browser: @user_agent\n\nTip: Don't recognize this login? When in doubt, it is safer to reset your password and ensure your account is healthy.\n\n-- [site:name] team", array(
'@user_agent' => $params['detection']['user_agent'],
'@hostname' => ip_address(),
), array(
'langcode' => $langcode,
));
$variables = array(
'user' => $params['account'],
);
$message['subject'] = token_replace($subject, $variables, array(
'language' => $language,
'callback' => 'user_mail_tokens',
'sanitize' => FALSE,
'clear' => TRUE,
));
$message['body'][] = token_replace($body, $variables, array(
'language' => $language,
'callback' => 'user_mail_tokens',
'sanitize' => FALSE,
'clear' => TRUE,
));
}
}