function queue_mail_mail_alter in Queue Mail 8
Same name and namespace in other branches
- 7 queue_mail.module \queue_mail_mail_alter()
Implements hook_mail_alter().
File
- ./
queue_mail.module, line 18 - The Queue Mail module.
Code
function queue_mail_mail_alter(&$message) {
$message['queued'] = FALSE;
// Avoid queueing a message if it is not going to be sent, as it would be
// skipped by our queue worker anyway.
if (empty($message['send'])) {
return;
}
$config = \Drupal::config('queue_mail.settings');
$mail_keys = $config
->get('queue_mail_keys');
if (\Drupal::service('path.matcher')
->matchPath($message['id'], $mail_keys)) {
// Save theme that is used to format mail.
$message['theme'] = \Drupal::service('theme.manager')
->getActiveTheme()
->getName();
// Add message to the queue.
$id = _queue_mail_get_queue()
->createItem($message);
// Was the message added to queue?
$message['queued'] = $id ? TRUE : FALSE;
// Prevent the message from being sent instantly.
$message['send'] = FALSE;
}
}