You are here

public function Mandrill_MessagesTest::send in Mandrill 7.2

See also

Mandrill_Messages::send()

File

tests/includes/mandrill_messages_test.inc, line 15
A virtual Mandrill Messages API implementation for use in testing.

Class

Mandrill_MessagesTest
@file A virtual Mandrill Messages API implementation for use in testing.

Code

public function send($message, $async = FALSE, $ip_pool = NULL, $send_at = NULL) {
  if (!isset($message['to']) || empty($message['to'])) {
    return $this->master
      ->getErrorResponse(12, 'ValidationError', 'No recipients defined.');
  }
  $response = array();
  foreach ($message['to'] as $recipient) {
    $recipient_response = array(
      'email' => $recipient['email'],
      'status' => '',
      'reject_reason' => '',
      '_id' => uniqid(),
    );
    if (valid_email_address($recipient['email'])) {
      $recipient_response['status'] = 'sent';
    }
    else {
      $recipient_response['status'] = 'invalid';
    }
    $response[] = $recipient_response;
  }
  return $response;
}