You are here

function uc_coupon_purchase_email in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 6 uc_coupon_purchase/uc_coupon_purchase.ca.inc \uc_coupon_purchase_email()
  2. 7.2 uc_coupon_purchase/uc_coupon_purchase.rules.inc \uc_coupon_purchase_email()

Action callback to send an e-mail regarding coupon purchase.

1 string reference to 'uc_coupon_purchase_email'
uc_coupon_purchase_default_rules_configuration in uc_coupon_purchase/uc_coupon_purchase.rules_defaults.inc
Implements hook_default_rules_configuration().

File

uc_coupon_purchase/uc_coupon_purchase.rules.inc, line 216
Rules integration for uc_coupon_purchase

Code

function uc_coupon_purchase_email($order, $coupon, $from, $addresses, $subject, $message, $format) {
  $settings = array(
    'from' => $from,
    'subject' => $subject,
    'message' => $message,
    'format' => $format,
    'replacements' => array(),
  );

  // Split up our recipient e-mail addresses.
  $recipients = array();
  foreach (explode("\n", $addresses) as $address) {
    $recipients[] = trim($address);
  }

  // Send the e-mails.
  foreach ($recipients as $email) {
    $sent = drupal_mail('uc_order', 'action-mail', $email, uc_store_mail_recipient_language($email), $settings, empty($settings['from']) ? uc_store_email_from() : $settings['from']);
    if (!$sent['result']) {
      watchdog('uc_order', 'Attempt to e-mail @email concerning order @order_id failed.', array(
        '@email' => $email,
        '@order_id' => $order->order_id,
      ), WATCHDOG_ERROR);
    }
  }
}