function uc_recurring_action_renewal_email in UC Recurring Payments and Subscriptions 7.2
Same name and namespace in other branches
- 6.2 uc_recurring.ca.inc \uc_recurring_action_renewal_email()
Send an email with order and recurring fee replacement tokens.
The recipients, subject, and message fields take order token replacements.
See also
uc_recurring_action_renewal_email_form()
1 string reference to 'uc_recurring_action_renewal_email'
- uc_recurring_ca_action in ./
uc_recurring.ca.inc - Implements hook_ca_action().
File
- ./
uc_recurring.ca.inc, line 353 - This file contains the Conditional Actions hooks and functions necessary to make the recurring-related entity, conditions, events, and actions work.
Code
function uc_recurring_action_renewal_email($order, $recurring_fee, $settings) {
$account = uc_order_user_load($order);
// Token replacements for the subject and body
$settings['replacements'] = array(
'global' => NULL,
'order' => $order,
'user' => $account,
'recurring_fee' => $recurring_fee,
);
// Replace tokens and parse recipients.
$recipients = array();
$addresses = token_replace_multiple($settings['addresses'], $settings['replacements']);
foreach (explode("\n", $addresses) as $address) {
$recipients[] = trim($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('ca', 'Attempt to e-mail @email concerning order @order_id failed.', array(
'@email' => $email,
'@order_id' => $order->order_id,
), WATCHDOG_ERROR);
}
}
}