function emaillog_mail in Logging and alerts 8
Same name and namespace in other branches
- 6.2 emaillog/emaillog.module \emaillog_mail()
- 6 emaillog/emaillog.module \emaillog_mail()
- 7.2 emaillog/emaillog.module \emaillog_mail()
- 7 emaillog/emaillog.module \emaillog_mail()
- 2.0.x emaillog/emaillog.module \emaillog_mail()
Implements hook_mail().
File
- emaillog/
emaillog.module, line 100 - Drupal Module: Email Logging and Alerts.
Code
function emaillog_mail($key, &$message, $params) {
if ($key == 'alert') {
$severity_levels = RfcLogLevel::getLevels();
$message_body = new FormattableMarkup($params['message'], $params['variables']);
$vars = [
'@site_name' => \Drupal::config('system.site')
->get('name'),
'@severity_desc' => Unicode::ucfirst($severity_levels[$params['severity']]
->render()),
'@dblog_message' => Unicode::truncate(strip_tags($message_body), 60, TRUE, TRUE),
];
// Legacy email subject.
if (\Drupal::config('emaillog.settings')
->get('emaillog_legacy_subject')) {
$message['subject'] = t('[@site_name] @severity_desc: Alert from your web site', $vars);
}
else {
$message['subject'] = t('[@site_name] @severity_desc: @dblog_message', $vars);
}
$emaillog_theme_element = [
'#theme' => 'emaillog',
'#log' => $params,
];
$message['body'][] = render($emaillog_theme_element);
}
}