Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Illuminate/Mail/Transport/SparkPostTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)

$message->setBcc([]);

$this->client->post('https://api.sparkpost.com/api/v1/transmissions', [
$response = $this->client->post('https://api.sparkpost.com/api/v1/transmissions', [
'headers' => [
'Authorization' => $this->key,
],
Expand All @@ -66,6 +66,8 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
], $this->options),
]);

$message->getHeaders()->addTextHeader('X-SparkPost-Transmission-ID', $this->getTransmissionId($response));

$this->sendPerformed($message);

return $this->numberOfRecipients($message);
Expand Down Expand Up @@ -98,6 +100,19 @@ protected function getRecipients(Swift_Mime_Message $message)
return $recipients;
}

/**
* Get the transmission ID from the response.
*
* @param \GuzzleHttp\Psr7\Response $response
* @return string
*/
protected function getTransmissionId($response)
{
$result = json_decode($response->getBody()->getContents());

return object_get($result, 'results.id');
}

/**
* Get the API key being used by the transport.
*
Expand Down