function uc_roles_action_user_email in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_roles/uc_roles.ca.inc \uc_roles_action_user_email()
Send an email with order and role replacement tokens.
The recipients, subject, and message fields take order token replacements.
See also
uc_roles_action_user_email_form()
1 string reference to 'uc_roles_action_user_email'
- uc_roles_rules_action_info in uc_roles/
uc_roles.rules.inc - Implements hook_rules_action_info().
File
- uc_roles/
uc_roles.rules.inc, line 279 - Rules hooks for uc_roles.module.
Code
function uc_roles_action_user_email($account, $role_expiration, $from, $addresses, $subject, $message, $format) {
$settings = array(
'from' => $from,
'addresses' => $addresses,
'subject' => $subject,
'message' => $message,
'format' => $format,
);
// Token replacements for the subject and body.
$settings['replacements'] = array(
'user' => $account,
'uc_role' => $role_expiration,
);
// Replace tokens and parse recipients.
$recipients = array();
$addresses = token_replace($settings['addresses'], $settings['replacements']);
foreach (explode("\n", $addresses) as $address) {
$address = trim($address);
// Remove blank lines.
if (!empty($address)) {
$recipients[] = $address;
}
}
// Send to each recipient.
foreach ($recipients as $email) {
$sent = drupal_mail('uc_order', 'action-mail', $email, uc_store_mail_recipient_language($email), $settings, $settings['from']);
if (!$sent['result']) {
watchdog('uc_roles', 'Attempt to e-mail @email concerning role notification failed.', array(
'@email' => $email,
), WATCHDOG_ERROR);
}
}
}