You are here

public function ClientService::sendMessage in Sparkpost email 8

Same name and namespace in other branches
  1. 8.2 src/ClientService.php \Drupal\sparkpost\ClientService::sendMessage()

Parameters

array $message:

Return value

array

Throws

\SparkPost\SparkPostException

Overrides ClientServiceInterface::sendMessage

File

src/ClientService.php, line 53

Class

ClientService
Class ClientService.

Namespace

Drupal\sparkpost

Code

public function sendMessage(array $message) {
  $config = $this->configFactory
    ->get('sparkpost.settings');
  $client = $this
    ->getClient();
  $message['content']['from'] = [
    'name' => $config
      ->get('sender_name'),
    'email' => $config
      ->get('sender'),
  ];
  $promise = $client->transmissions
    ->post($message);
  $response = $promise
    ->wait();
  return $response
    ->getBody();
}