Closed
Description
PHP 8.4
SendGrid 8.1.11
I get this error message when sending an email:
SendGrid\Client::makeRequest(): Argument #3 ($body) must be of type ?array, SendGrid\Mail\Mail give called in /var/www/html/my-project/vendor/sendgrid/php-http-client/lib/Client.php on line 662
My code:
$fromEmail = "info@example.com";
$fromName = "Example Solutions";
$email = new Mail();
$email->setFrom($fromEmail, $fromName);
$email->addTo($Email, $Name);
$email->setSubject("Subject");
$email->addContent("text/plain", "Find attached the spec sheet.");
$email->addContent(
"text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
);
$sendGrid = new \SendGrid($_ENV['SENDGRID_API_KEY']);
$sendGridResponse = $sendGrid->send($email);
if ($sendGridResponse->statusCode() === 202) {
} else {
throw new Exception("Caught exception: " . $sendGridResponse->body());
}
Metadata
Metadata
Assignees
Labels
No labels