Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.1003 diff -u -p -r1.1003 system.module --- modules/system/system.module 4 Jan 2011 00:56:23 -0000 1.1003 +++ modules/system/system.module 22 Jan 2011 13:29:47 -0000 @@ -3085,10 +3085,10 @@ function system_send_email_action_form($ $form['recipient'] = array( '#type' => 'textfield', - '#title' => t('Recipient'), + '#title' => t('Recipients'), '#default_value' => $context['recipient'], '#maxlength' => '254', - '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'), + '#description' => t('The email address(es) to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc., if you would like to send an e-mail to the author of the original post. Use commas to separate multiple recipients.'), ); $form['subject'] = array( '#type' => 'textfield', @@ -3114,10 +3114,12 @@ function system_send_email_action_form($ function system_send_email_action_validate($form, $form_state) { $form_values = $form_state['values']; // Validate the configuration form. - if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) { - // We want the literal %author placeholder to be emphasized in the error message. - form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]'))); - } + foreach (explode(',', $form_values['recipient']) as $recipient) { + if (!valid_email_address(trim($recipient)) && strpos(trim($recipient), ':mail') === FALSE) { + // We want the literal %author placeholder to be emphasized in the error message. + form_set_error('recipient', t('Enter valid comma separated email address(es) or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]'))); + } + } } /** @@ -3143,7 +3145,7 @@ function system_send_email_action_submit * provided. * @param array $context * Array with the following elements: - * - 'recipient': E-mail message recipient. This will be passed through + * - 'recipient': E-mail message recipients. This will be passed through * token_replace(). * - 'subject': The subject of the message. This will be passed through * token_replace(). @@ -3158,25 +3160,27 @@ function system_send_email_action($entit $context['node'] = $entity; } - $recipient = token_replace($context['recipient'], $context); - - // If the recipient is a registered user with a language preference, use - // the recipient's preferred language. Otherwise, use the system default - // language. - $recipient_account = user_load_by_mail($recipient); - if ($recipient_account) { - $language = user_preferred_language($recipient_account); - } - else { - $language = language_default(); - } + $recipients = token_replace($context['recipient'], $context); $params = array('context' => $context); - - if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) { - watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient)); - } - else { - watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient)); + + foreach (explode(',', $recipients) as $recipient) { + $recipient = trim($recipient); + // If the recipient is a registered user with a language preference, use + // the recipient's preferred language. Otherwise, use the system default + // language + $recipient_account = user_load_by_mail($recipient); + if ($recipient_account) { + $language = user_preferred_language($recipient_account); + } + else { + $language = language_default(); + } + if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) { + watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient)); + } + else { + watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient)); + } } }