You are here

function Messaging_Send_Method::message_multisend in Messaging 6.4

Message default callback: send iterating over all destinations

This can be overridden by any sending method that can send multiple messages in a more efficient way.

File

includes/messaging_method.class.inc, line 364
Drupal Messaging Framework - Send_Method class file

Class

Messaging_Send_Method
Sending method, implements all specific method functionality

Code

function message_multisend($message) {
  $success = $fail = array();
  foreach ($message
    ->get_addresses() as $to) {
    if ($this
      ->send_address($to, $message)) {
      $success[] = $to;
    }
    else {
      $fail[] = $to;
    }
  }

  // If sent, set time. If failed set error
  if ($success) {
    $message->sent = time();
  }
  if ($fail) {
    $destinations = check_plain(implode(', ', $fail));
    $message
      ->set_error("Sending ({$this->method}) to some destinations failed: {$destinations}.");
  }
  return $success && !$fail;
}