Closed wittsparks closed 1 year ago
I'm currently using a fork of this package to add support for subaccounts. Here is my change to src/Transport/SparkPostTransport.php:
public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage { $recipients = $this->getRecipients($message); $headers = ['Authorization' => $this->key]; $subaccount_id = $message->getHeaders()->get('subaccount_id'); if ($subaccount_id) { $headers['X-MSYS-SUBACCOUNT'] = $subaccount_id->getValue(); } $response = $this->client->request('POST', $this->getEndpoint() . '/transmissions', [ 'headers' => $headers, 'json' => array_merge([ ...
To add a subaccount to a message, add it to the message headers in a Mailable:
$this->withSymfonyMessage(function ($message) use ($subaccount_id) { $headers = $message->getHeaders(); $headers->addTextHeader('subaccount_id', $subaccount_id); });
I'd be happy to submit this as a PR.
Hi @wittsparks seems ok, create a PR and we will look into it.
Thanks for the PR, its merged
I'm currently using a fork of this package to add support for subaccounts. Here is my change to src/Transport/SparkPostTransport.php:
To add a subaccount to a message, add it to the message headers in a Mailable:
I'd be happy to submit this as a PR.