Skip to content

Commit

Permalink
Merge pull request #247 from DavePodosyan/patch-1
Browse files Browse the repository at this point in the history
Fix SparkPost integration: correct recipient address handling and content headers format
  • Loading branch information
techjewel authored Nov 9, 2024
2 parents aadea71 + 9e9f963 commit 901e930
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions app/Services/Mailer/Providers/SparkPost/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,16 @@ public function postSend()
{
$body = [
'options' => [
'sandbox' => defined('FLUENTMAIL_TEST_EMAIL')
'sandbox' => false
],
'content' => [
'from' => $this->getFrom(),
'subject' => $this->getSubject(),
'html' => $this->phpMailer->Body,
'text' => $this->phpMailer->AltBody,
'headers' => []
],
'recipients' => [
[
'address' => [
'name' => $this->getParam('sender_name'),
'email' => $this->getParam('sender_email')
]
]
'headers' => (object) []
],
'recipients' => $this->getTo(),
'cc' => $this->getCarbonCopy(),
'bcc' => $this->getBlindCarbonCopy()
];
Expand Down Expand Up @@ -114,6 +107,21 @@ protected function getFrom()
return $from;
}

protected function getTo()
{
$address = [];

foreach ($this->getParam('to') as $to) {
$address[] = [
'address' => [
'email' => $to['email']
]
];
}

return $address;
}

protected function getReplyTo()
{
if ($replyTo = $this->getParam('headers.reply-to')) {
Expand Down

0 comments on commit 901e930

Please sign in to comment.