Ticket #1484542 (closed Patches: fixed)

Opened 3 years ago

Last modified 5 months ago

Add optional support to restrict total number of recipients per message.

Reported by: phallstrom Owned by:
Priority: 5 Milestone: 0.4-beta
Component: Core functionality Version: 0.1-rc1
Severity: normal Keywords:
Cc:

Description

The following patch allows for an optional configuration parameter "max_recipient_count" which if set will restrict the total number of recipients (To, Cc, Bcc) to that number.

Index: config/main.inc.php
===================================================================
--- config/main.inc.php (revision 17)
+++ config/main.inc.php (working copy)
@@ -103,6 +103,9 @@
 // how many seconds must pass between emails sent by a user
 $rcmail_config['sendmail_delay'] = 15; 
 
+// maximum number of recipients per message. undefine or set to 0 to disable
+$rcmail_config['max_recipient_count'] = 25; 
+
 // session domain
 $rcmail_config['session_domain'] = ".example.com";
 
Index: program/localization/en_US/messages.inc
===================================================================
--- program/localization/en_US/messages.inc     (revision 17)
+++ program/localization/en_US/messages.inc     (working copy)
@@ -42,6 +42,7 @@
 
 $messages['sendingfailed'] = 'Failed to send message';
 $messages['senttooquickly'] = 'You have sent too many messaages too quickly. Please wait a moment before sending this one.';
+$messages['too_many_recipients'] = 'Your message has too many recipients.  Please reduce the number of recipients.';
 $messages['errorsaving'] = 'An error occured while saving';
 $messages['errormoving'] = 'Could not move the message';
 $messages['errordeleting'] = 'Could not delete the message';
Index: program/steps/mail/sendmail.inc
===================================================================
--- program/steps/mail/sendmail.inc     (revision 17)
+++ program/steps/mail/sendmail.inc     (working copy)
@@ -191,6 +191,24 @@
 if (!empty($identity_arr['bcc']))
   $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc'];
 
+
+if (intval($CONFIG['max_recipient_count']) > 0)
+  {
+  $recipient_count = substr_count($headers['To'], ',') + 1;
+  if (!empty($headers['Cc']))
+    $recipient_count += substr_count($headers['Cc'], ',') + 1;
+  if (!empty($headers['Bcc']))
+    $recipient_count += substr_count($headers['Bcc'], ',') + 1;
+
+  if ($recipient_count > intval($CONFIG['max_recipient_count']))
+    {
+    $OUTPUT->show_message('too_many_recipients', 'error');
+    $OUTPUT->send('iframe');
+    return;
+    }
+  }
+
+
 // add subject
 $headers['Subject'] = trim(get_input_value('_subject', RCUBE_INPUT_POST, FALSE, $message_charset));

Change History

Changed 3 years ago by seansan

  • milestone set to 0.1.5

Patch provided. Do we want this?

review in 0.1.5

nice paradox with #1484514 ;)

Changed 2 years ago by thomasb

  • milestone changed from 0.1.5 to 0.4-beta

Changed 6 months ago by Lazlo

Changed 5 months ago by alec

Counting commas is not a good method. There could be commas in quoted recipient names. We should use rcmail_email_input_format function (sendmail.inc) to count recipients.

Changed 5 months ago by alec

  • status changed from new to closed
  • resolution set to fixed

Implemented in r3468.

Changed 5 months ago by alec

  • component changed from Client Scripts to Core functionality
Note: See TracTickets for help on using tickets.