You are here

public function MandrillAPI::getMessages in Mandrill 8

Gets messages received by an email address.

Parameters

$email: The email address of the message recipient.

Return value

array

Overrides MandrillAPIInterface::getMessages

1 method overrides MandrillAPI::getMessages()
MandrillTestAPI::getMessages in src/MandrillTestAPI.php
Gets messages received by an email address.

File

src/MandrillAPI.php, line 56

Class

MandrillAPI
Service class to integrate with Mandrill.

Namespace

Drupal\mandrill

Code

public function getMessages($email) {
  $messages = array();
  try {
    if ($mandrill = $this
      ->getAPIObject()) {
      $messages = $mandrill->messages
        ->search("email:{$email}");
    }
  } catch (\Exception $e) {
    \Drupal::messenger()
      ->addError(t('Mandrill: %message', array(
      '%message' => $e
        ->getMessage(),
    )));
    $this->log
      ->error($e
      ->getMessage());
  }
  return $messages;
}