From 46b2b479b6df3686982434cfb0abb968c9df3456 Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Fri, 22 Apr 2011 12:46:18 -0400
Subject: [PATCH] Issue #800434 by bar.hanssens: Allow hook_mail_alter implementations to cancel mail.

---
 includes/mail.inc |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/includes/mail.inc b/includes/mail.inc
index d2febed39686c9bf3f6f7a2bf99fa1377d09f4de..390acc6c0832c86bbb47412dc043f96fbd0289cf 100644
--- a/includes/mail.inc
+++ b/includes/mail.inc
@@ -108,6 +108,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
     'from'     => isset($from) ? $from : $default_from,
     'language' => $language,
     'params'   => $params,
+    'cancel'   => !$send,
     'subject'  => '',
     'body'     => array()
   );
@@ -147,7 +148,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
   $message = $system->format($message);
 
   // Optionally send e-mail.
-  if ($send) {
+  if ($send && empty($message['cancel'])) {
     $message['result'] = $system->mail($message);
 
     // Log errors
-- 
1.7.1

