You are here

function drush_simplenews_spool_send in Simplenews 7

Same name and namespace in other branches
  1. 8.2 simplenews.drush.inc \drush_simplenews_spool_send()
  2. 8 simplenews.drush.inc \drush_simplenews_spool_send()
  3. 7.2 simplenews.drush.inc \drush_simplenews_spool_send()
  4. 3.x simplenews.drush.inc \drush_simplenews_spool_send()

Drush command to send the mail spool queue.

File

./simplenews.drush.inc, line 59
Drush commands for administer Simplenews.

Code

function drush_simplenews_spool_send($limit = FALSE) {
  module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
  if ($limit === FALSE) {
    $limit = variable_get('simplenews_throttle');
  }
  elseif ($limit == 0) {
    $limit = SIMPLENEWS_UNLIMITED;
  }
  $start_time = microtime(TRUE);
  $sent = simplenews_mail_spool($limit);
  simplenews_clear_spool();
  simplenews_send_status_update();
  $durance = round(microtime(TRUE) - $start_time, 2);

  // Report the number of sent mails.
  if ($sent > 0) {
    $remaining = simplenews_count_spool();
    if (drush_get_option(array(
      'p',
      'pipe',
    ))) {

      // For pipe, print the sent first and then the remaining count, separated by a space.
      drush_print_pipe($sent . " " . $remaining);
    }
    else {
      drush_log(dt('Sent @count mails from the queue in @sec seconds.', array(
        '@count' => $sent,
        '@sec' => $durance,
      )), 'status');
      drush_log(dt('Remaining simplenews mail spool count: @count', array(
        '@count' => $remaining,
      )), 'status');
    }
  }
}