Ticket #1484542 (closed Patches: fixed)
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
Note: See
TracTickets for help on using
tickets.
