Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / mail_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/mail_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/mail_alter.twig
new file mode 100644 (file)
index 0000000..e476e64
--- /dev/null
@@ -0,0 +1,14 @@
+/**
+ * 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 " . variable_get('site_name', t('Drupal'));
+  }
+}