Index: modules/reroute_email/reroute_email.module
===================================================================
--- modules/reroute_email/reroute_email.module	(revision 24988)
+++ modules/reroute_email/reroute_email.module	(working copy)
@@ -3,6 +3,7 @@
 // $Id: reroute_email.module,v 1.6 2008/07/24 14:32:35 kbahey Exp $
 
 define('REROUTE_EMAIL_ADDRESS',  'reroute_email_address');
+define('REROUTE_EMAIL_SILENT',  'reroute_email_silent');
 
 /**
  * Implementation of hook_perm().
@@ -15,8 +16,8 @@
   $items = array();
 
   $items['admin/settings/reroute_email'] = array(
-    'title'              => t('Reroute Email'),
-    'description'        => t('Reroute emails to a test address.'),
+    'title'              => t('Reroute e-mail'),
+    'description'        => t('Reroute e-mails to a test address.'),
     'page callback'      => 'drupal_get_form',
     'page arguments'     => array('reroute_email_settings'),
     'access arguments'   => array('administer reroute email'),
@@ -32,9 +33,15 @@
     '#required'      => TRUE,
     '#default_value' => variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from')),
     '#size'          => 35,
-    '#description'   => t('The email address to reroute all emails from the site to.')
+    '#description'   => t('The e-mail address to reroute all e-mails from the site to.')
   );
-
+  $form[REROUTE_EMAIL_SILENT] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Silent BCC'),
+    '#default_value' => variable_get(REROUTE_EMAIL_SILENT, 0),
+    '#description'   => t('Reroute all e-mails silently by sending all e-mails to out both the orginal recipents and reroute recipient.'),
+  );
+  
   return system_settings_form($form);
 }
 
@@ -44,28 +51,47 @@
   if (!empty($message) && is_array($message)) {
     $mailkey = isset($message['id']) ? $message['id'] : t('<mail id> is missing');
     $to = isset($message['to']) ? $message['to'] : t('<to> is missing');
-  // Suppress Bcc and Cc fields otherwise email will still go out to those addresses
-    if (isset($message['headers']) && is_array($message['headers'])) {
-      if (isset($message['headers']['Bcc'])) {
-        unset($message['headers']['Bcc']);
+    if (variable_get(REROUTE_EMAIL_SILENT, 0)) {
+      if (isset($message['headers']) && is_array($message['headers'])) {
+        if (isset($message['headers']['Bcc'])) {
+          $message['headers']['Bcc'] .= ', ' . variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from'));
+        }
+        else {
+          $message['headers']['Bcc'] = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from'));
+        }
       }
-      if (isset($message['headers']['Cc'])) {
-        unset($message['headers']['Cc']);
+    }
+    else {
+      // Suppress Bcc and Cc fields otherwise e-mail will still go out to those addresses
+      if (isset($message['headers']) && is_array($message['headers'])) {
+        if (isset($message['headers']['Bcc'])) {
+          unset($message['headers']['Bcc']);
+        }
+        if (isset($message['headers']['Cc'])) {
+          unset($message['headers']['Cc']);
+        }
       }
+      
     }
   }
   
   // Format a message to show at the top
-  $msg[] = t("This email was rerouted.");
-  $msg[] = t("Web site: @site", array('@site' => $base_url));
-  $msg[] = t("Mail key: @key", array('@key' => $mailkey));
-  $msg[] = t("Originally to: <@to>", array('@to' => $to));
-  $msg[] = "-----------------------";
+  if (variable_get(REROUTE_EMAIL_SILENT, 0)) {
+    watchdog('content', 'BCC to "@bcc-address" of an e-mail to "@to-address".', array('@to-address' => $message['to'], '@bcc-address' => variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from'))), WATCHDOG_INFO);
+  }
+  else {
+    $msg[] = t("This e-mail was rerouted.");
+    $msg[] = t("Web site: @site", array('@site' => $base_url));
+    $msg[] = t("Mail key: @key", array('@key' => $mailkey));
+    $msg[] = t("Originally to: <@to>", array('@to' => $to));
+    $msg[] = "-----------------------";
+    
+    // Prepend to the body of the e-mail
+    $message['body'] = array_merge($msg, isset($message['body']) ? (is_array($message['body']) ? $message['body'] : array($message['body'])) : array());
 
-  // Prepend to the body of the email
-  $message['body'] = array_merge($msg, isset($message['body']) ? (is_array($message['body']) ? $message['body'] : array($message['body'])) : array());
-
-  // Change the $to address to be the one we defined
-  $message['to'] = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from'));
+    // Change the $to address to be the one we defined
+    $message['to'] = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from'));
+  }
+  
 }
 
