--- C:/original/mass_contact.module	Thu Oct 23 22:14:12 2008
+++ C:/new/mass_contact.module	Fri Feb 13 11:47:26 2009
@@ -669,7 +669,13 @@
     '#default_value' => variable_get('mass_contact_hourly_threshold', 3),
     '#description'   => t('The maximum number of Mass Contact form submissions a user can perform per hour.'),
   );
-
+
+  $form['mass_contact_job_queue'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Use Job Queue to send mails, when available.'),
+    '#default_value' => variable_get('mass_contact_job_queue', 1),
+  );
+  
   return system_settings_form($form);
 }  //  End of mass_contact_admin_settings().
 
@@ -1371,12 +1377,22 @@
             }
           }
           else {
-*/
-            $success = drupal_mail('mass_contact', 'mail_page', $to, language_default(), $params, $from_email);
+*/
+          if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+         	
+          	job_queue_add('drupal_mail', 'Queued Mass Contact Mail',array('mass_contact','mail_page',$to, language_default(), $params, $from_email));
+          	$success['result'] = true;
+          } else {
+            $success = drupal_mail('mass_contact', 'mail_page', $to, language_default(), $params, $from_email);
+          }
 //          }
 
-          if ($success['result']) {
-            drupal_set_message(t('[Success] Send #!ccc: -e-mails', array('!ccc' => $ccc, '-e-mails' => $recipient_send)));
+          if ($success['result']) {
+          	if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          		drupal_set_message(t('[Success] Queued #!ccc: -e-mails', array('!ccc' => $ccc, '-e-mails' => $recipient_send)));
+          	} else {
+          		drupal_set_message(t('[Success] Send #!ccc: -e-mails', array('!ccc' => $ccc, '-e-mails' => $recipient_send)));
+          	}
           }
           else {
             ++$send_error;
@@ -1413,17 +1429,31 @@
           }
         }
         else {
-*/
-          $success = drupal_mail('mass_contact', 'mail_page', $to, language_default(), $params, $from_email);
+*/
+          if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          	job_queue_add('drupal_mail', 'Queued Mass Contact Mail',array('mass_contact','mail_page',$to, language_default(), $params, $from_email));
+          	$success['result'] = true;
+          } else {
+            $success = drupal_mail('mass_contact', 'mail_page', $to, language_default(), $params, $from_email);
+          }        
+         
 //        }
 
         // Send a copy to self, if requested.
-        if ($form_state['values']['copy'] && !$bcc) {
-          drupal_mail('mass_contact', 'user-copy', $from_email, language_default(), $params, $from_email);
+        if ($form_state['values']['copy'] && !$bcc) {
+          if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          	job_queue_add('drupal_mail', 'Queued Mass Contact Mail', array('mass_contact', 'user-copy', $from_email, language_default(), $params, $from_email));
+          } else {
+            drupal_mail('mass_contact', 'user-copy', $from_email, language_default(), $params, $from_email);
+          }        	
         }
 
-        if ($success['result']) {
-          drupal_set_message(t('[Success] Send Remainder: -e-mails', array('-e-mails' => $recipient_send)));
+        if ($success['result']) {
+            if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          		drupal_set_message(t('[Success] Queued Remainder: -e-mails', array('-e-mails' => $recipient_send)));
+          	} else {
+          		drupal_set_message(t('[Success] Send Remainder: -e-mails', array('-e-mails' => $recipient_send)));
+          	}
         }
         else {
           ++$send_error;
@@ -1461,17 +1491,32 @@
         }
       }
       else {
-*/
-        $success = drupal_mail('mass_contact', 'mail_page', $to, language_default(), $params, $from_email);
+*/
+          if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          	job_queue_add('drupal_mail', 'Queued Mass Contact Mail',array('mass_contact','mail_page',$to, language_default(), $params, $from_email));
+          	$success['result'] = true;
+          } else {
+            $success = drupal_mail('mass_contact', 'mail_page', $to, language_default(), $params, $from_email);
+          }      
+        
 //      }
 
       // Send a copy to self, if requested.
-      if ($form_state['values']['copy'] && !$bcc) {
-        drupal_mail('mass_contact', 'user-copy', $from_email, language_default(), $params, $from_email);
+      if ($form_state['values']['copy'] && !$bcc) {
+          if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          	job_queue_add('drupal_mail', 'Queued Mass Contact Mail', array('mass_contact', 'user-copy', $from_email, language_default(), $params, $from_email));
+          } else {
+            drupal_mail('mass_contact', 'user-copy', $from_email, language_default(), $params, $from_email);
+          }      	
+        
       }
 
-      if ($success['result']) {
-        drupal_set_message(t('[Success] Send Once: -e-mails', array('-e-mails' => $recipientout)));
+      if ($success['result']) {
+            if ( (variable_get('mass_contact_job_queue', 1)) && ( function_exists('job_queue_add')) ) {
+          		drupal_set_message(t('[Success] Queued Once: -e-mails', array('-e-mails' => $recipientout)));
+          	} else {
+          		drupal_set_message(t('[Success] Send Once: -e-mails', array('-e-mails' => $recipientout)));
+          	}      	
       }
       else {
         ++$send_error;
