diff options
Diffstat (limited to 'modules/system/system.api.php')
-rw-r--r-- | modules/system/system.api.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php index a2e71d2cc..b2ae3192f 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -1903,11 +1903,19 @@ function hook_image_toolkits() { * - 'language': * The language object used to build the message before hook_mail_alter() * is invoked. + * - 'send': + * Set to FALSE to abort sending this email message. * * @see drupal_mail() */ function hook_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')); } } |