v1/vendor/chi-teck/drupal-code-generator/templates/hook/mail_alter.twig

15 lines
463 B
Twig

/**
* Implements hook_mail_alter().
*/
function {{ machine_name }}_mail_alter(&$message) {
if ($message['id'] == 'modulename_messagekey') {
if (!example_notifications_optin($message['to'], $message['id'])) {
// If the recipient has opted to not receive such messages, cancel
// sending.
$message['send'] = FALSE;
return;
}
$message['body'][] = "--\nMail sent out from " . \Drupal::config('system.site')->get('name');
}
}