Index: forward.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/forward/forward.module,v
retrieving revision 1.55.2.34
diff -u -p -r1.55.2.34 forward.module
--- forward.module	22 Mar 2010 19:14:41 -0000	1.55.2.34
+++ forward.module	16 Jul 2010 15:46:48 -0000
@@ -174,6 +174,21 @@ function forward_admin_settings() {
     '#rows' => 10,
     '#description' => t('This text appears if a user exceeds the flood control limit.  The value of the flood control limit setting will appear in place of !number in the message presented to users'),
   );
+  $form['forward_options']['forward_max_emails_per_mailing'] = array(
+    '#type' => 'select',
+    '#title' => t('Maximum emails allowed per mailing'),
+    '#default_value' => variable_get('forward_max_emails_per_mailing', 10),
+    '#options' => array('1' => '1', '5' => '5', '10' => '10', '15' => '15', '20' => '20', '25' => '25', '30' => '30', '35' => '35', '40' => '40', '50' => '50'),
+    '#description' => t('How many email addresses a user can use in the form at once. This will help prevent the forward module from being used for spamming.'),
+  );
+  $form['forward_options']['forward_max_emails_error'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Maximum emails error'),
+    '#default_value' => variable_get('forward_max_emails_error', t("You can't send to more than !number recipients at once. Please remove some email addresses and try again.")),
+    '#cols' => 40,
+    '#rows' => 5,
+    '#description' => t('This text appears if a user exceeds the maximum emails limit.  The value of the maximum emails limit setting will appear in place of !number in the message presented to users.'),
+  );
   $form['forward_options']['forward_message'] = array(
     '#type' => 'select',
     '#title' => t('Personal messages'),
@@ -623,6 +638,11 @@ function forward_form_validate($form, &$
   // convert addresses to an array
   $recipient_addresses = explode(',', $recipients);
 
+  // Check if the amount of recipients exceeds the maximum amount.
+  if (count($recipient_addresses) > variable_get('forward_max_emails_per_mailing', 10)) {
+    form_set_error('recipients', check_plain(t(variable_get('forward_max_emails_error', "You can't send to more than !number recipients at once. Please remove some email addresses and try again."), array('!number' => variable_get('forward_max_emails_per_mailing', 10)))));
+  }
+
   $bad_items = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:');
   $bad_string = FALSE;
   foreach ($bad_items as $item) {
