You are here

function views_send_batch_deliver in Views Send 7

Same name and namespace in other branches
  1. 8 views_send.module \views_send_batch_deliver()

Preparing and sending a message (coming from a batch job).

1 string reference to 'views_send_batch_deliver'
views_send_queue_mail in ./views_send.module
Assembles the email and queues it for sending.

File

./views_send.module, line 1186
The Views Send module.

Code

function views_send_batch_deliver($message, $plain_format, $attachments, &$context) {
  _views_send_prepare_mail($message, $plain_format, $attachments);
  if (!$message['send']) {
    $context['results'][] = t('Skipping sending message to %mail.', array(
      '%mail' => $message['to_mail'],
    ));
    return;
  }
  else {
    unset($message['send']);
  }
  $status = views_send_deliver($message);
  if ($status) {
    if (variable_get('views_send_debug', FALSE)) {
      watchdog('views_send', 'Message sent to %mail.', array(
        '%mail' => $message['to_mail'],
      ));
    }
    if (module_exists('rules')) {
      rules_invoke_event('views_send_email_sent', $message);
    }
  }
  else {
    $context['results'][] = t('Failed sending message to %mail - spooling it.', array(
      '%mail' => $message['to_mail'],
    ));

    // Queue the message to the spool table.
    db_insert('views_send_spool')
      ->fields($message)
      ->execute();
    if (module_exists('rules')) {
      rules_invoke_event('views_send_email_added_to_spool', $message);
    }
  }
}