51b6cc0e5edcdec57e1acffdc1eb251c223fdb21
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / mail_alter.twig
1 /**
2  * Implements hook_mail_alter().
3  */
4 function {{ machine_name }}_mail_alter(&$message) {
5   if ($message['id'] == 'modulename_messagekey') {
6     if (!example_notifications_optin($message['to'], $message['id'])) {
7       // If the recipient has opted to not receive such messages, cancel
8       // sending.
9       $message['send'] = FALSE;
10       return;
11     }
12     $message['body'][] = "--\nMail sent out from " . \Drupal::config('system.site')->get('name');
13   }
14 }