diff --git a/comment_notify.api.php b/comment_notify.api.php
new file mode 100644
index 0000000..e54cecf
--- /dev/null
+++ b/comment_notify.api.php
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * @file
+ * Hooks provided by comment notify module.
+ */
+
+/**
+ * Allow or deny sending mails in debug mode.
+ *
+ * @return
+ *   COMMENT_NOTIFY_DEBUG_ALLOW if the operation is to be allowed;
+ *   COMMENT_NOTIFY_DEBUG_DENY if the operation is to be denied;
+ *   COMMENT_NOTIFY_DEBUG_IGNORE to not affect this operation at all.
+ */
+function hook_comment_notify_debug($uid, $language, $message, $comment) {
+  // Deny sending mail if subject starts with the word debug
+  return strpos($message['subject'], 'debug') === 0;
+}
\ No newline at end of file
diff --git a/comment_notify.module b/comment_notify.module
index 87f2cb7..39d42cc 100644
--- a/comment_notify.module
+++ b/comment_notify.module
@@ -10,6 +10,24 @@ define('COMMENT_NOTIFY_DISABLED', 0);
 define('COMMENT_NOTIFY_NODE', 1);
 define('COMMENT_NOTIFY_COMMENT', 2);
 
+/**
+ * Modules should return this value from hook_comment_notify() to allow sending
+ * mail in debug mode.
+ */
+define('COMMENT_NOTIFY_DEBUG_ALLOW', 'allow');
+
+/**
+ * Modules should return this value from hook_comment_notify() to deny sending
+ * mail in debug mode.
+ */
+define('COMMENT_NOTIFY_DEBUG_DENY', 'deny');
+
+/**
+ * Modules should return this value from hook_comment_notify() to not affect
+ * sending mail in debug mode.
+ */
+define('COMMENT_NOTIFY_DEBUG_IGNORE', NULL);
+
 
 define('AUTHOR_MAILTEXT',
 'Hi [comment:node:author],
@@ -441,7 +459,9 @@ function _comment_notify_mailalert($comment) {
       $message[$k] = token_replace(t($v), array('comment' => $comment, 'node' => $node, 'user' => $user));
     }
 
-    drupal_mail('comment_notify', 'comment_notify_mail', $author->mail, $language, $message);
+    if (comment_notify_allow_mail($author->uid, $language, $message, $comment)) {
+      drupal_mail('comment_notify', 'comment_notify_mail', $author->mail, $language, $message);
+    }
     $sent_to[] = $author->mail;
   }
 
@@ -486,7 +506,9 @@ function _comment_notify_mailalert($comment) {
         $message[$k] = token_replace(t($v), array('comment' => $comment, 'node' => $node, 'user' => $user));
       }
 
-      drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
+      if (comment_notify_allow_mail($alert->uid, $language, $message, $comment)) {
+        drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
+      }
       $sent_to[] = $mail;
 
       // Make the mail link to user's /edit, unless it's an anonymous user.
@@ -670,3 +692,34 @@ function comment_notify_settings_validate($form, &$form_state) {
     form_set_error('comment_notify_available_alerts', 'You must enable at least one subscription mode.');
   }
 }
+
+
+/**
+ * Return TRUE if we are in not in debug mode, or if we are in debug mode
+ * atleast one module granted permission to send mail.
+ */
+function comment_notify_allow_mail($uid, $language, $message, $comment) {
+  $debug = variable_get('comment_notify_debug', FALSE);
+
+  if (!$debug) {
+    return TRUE;
+  }
+
+  // If we are in debug mode, allow implementing modules to decide if a mail
+  // sould be sent (i.e. "white-list" functionality).
+  // We grant access to sendind mail if both of the following conditions are
+  // met:
+  // - No modules say to deny access.
+  // - At least one module says to grant access.
+  // If no module specified either allow or deny, we fall deny sending an email.
+  $access = module_invoke_all('comment_notify_debug', $uid, $language, $message, $comment);
+  if (in_array(COMMENT_NOTIFY_DEBUG_DENY, $access, TRUE)) {
+    return FALSE;
+  }
+  elseif (in_array(COMMENT_NOTIFY_DEBUG_ALLOW, $access, TRUE)) {
+    return TRUE;
+  }
+
+  // Fallback to no-sending, since we are in debug mode.
+  return FALSE;
+}
