Skip to content

Commit

Permalink
Fix personalization object
Browse files Browse the repository at this point in the history
  • Loading branch information
moux2003 committed Jul 30, 2018
1 parent 06204bc commit feefef8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Services/SendGridTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
$contentType = $finfo->buffer($message->getBody());
$mail->addContent(new SendGrid\Mail\Content($contentType, $message->getBody()));

$personalization = new SendGrid\Mail\Personalization();
// personalization
if (!empty($mail->getPersonalizations())) {
$personalization = $mail->getPersonalizations()[0];
} else {
$personalization = new SendGrid\Mail\Personalization();
$mail->addPersonalization($personalization);
}

// process TO
if ($toArr = $message->getTo()) {
Expand Down Expand Up @@ -167,8 +173,6 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
}
}

$mail->addPersonalization($personalization);

$sendGrid = new SendGrid($this->sendGridApiKey, $this->httpClientOptions);

$response = $sendGrid->client->mail()->send()->post($mail);
Expand Down

0 comments on commit feefef8

Please sign in to comment.