You are here

public function MessageWrapper::sendMessage in Sparkpost email 8.2

Sends the message.

Return value

bool If it was a success or not.

Overrides MessageWrapperInterface::sendMessage

File

src/MessageWrapper.php, line 122

Class

MessageWrapper
Message wrapper class.

Namespace

Drupal\sparkpost

Code

public function sendMessage() {
  try {
    $data = $this->clientService
      ->sendMessage($this->sparkpostMessage);
    $this
      ->setResult($data);
    \Drupal::moduleHandler()
      ->invokeAll('sparkpost_mailsend_success', [
      $this,
    ]);
    return TRUE;
  } catch (SparkPostException $e) {
    $this
      ->setApiResponseException($e);
  } catch (\Exception $e) {

    // @todo Handle sparkpost exceptions separately.
  }
  \Drupal::moduleHandler()
    ->invokeAll('sparkpost_mailsend_error', [
    $this,
  ]);
  return FALSE;
}