You are here

protected function MandrillTestService::handleSendResponse in Mandrill 8

Response handler for sent messages.

Parameters

array $response: Response from the Mandrill API.

array $message: The sent message.

Return value

bool TRUE if the message was sent or queued without error.

Overrides MandrillService::handleSendResponse

File

src/MandrillTestService.php, line 13

Class

MandrillTestService
Test Mandrill service.

Namespace

Drupal\mandrill

Code

protected function handleSendResponse($response, $message) {
  if (isset($response['status'])) {

    // There was a problem sending the message.
    return FALSE;
  }
  foreach ($response as $result) {

    // Allow other modules to react based on a send result.
    \Drupal::moduleHandler()
      ->invokeAll('mandrill_mailsend_result', [
      $result,
    ], [
      $message,
    ]);
    switch ($result['status']) {
      case "error":
      case "invalid":
      case "rejected":
        return FALSE;
    }
  }
  return TRUE;
}