function rb_cck_action_email_userreference in Rules Bonus Pack 6
Action for 'rb_cck_action_email_userreference'.
File
- ./
rb_cck.module, line 638 - Functions for extending CCK field management with Rules.
Code
function rb_cck_action_email_userreference($node, $settings) {
// Build a list of recipient e-mail addresses, comma separated.
$recipients = $node->{$settings['field']};
$to_addresses = array();
foreach ($recipients as $recipient) {
$account = user_load($recipient['uid']);
$to_addresses[] = $account->mail;
}
$to = implode(', ', $to_addresses);
$from = $settings['from'] ? str_replace(array(
"\r",
"\n",
), '', $settings['from']) : NULL;
$message = drupal_mail('rules', 'rules_action_mail', $to, language_default(), $settings, $from);
if ($message['result']) {
watchdog('rules', 'Successfully sent email to %recipient', array(
'%recipient' => $to,
));
}
}