Skip to content

SendGrid\\Client::makeRequest(): Argument #3 ($body) must be of type ?array, SendGrid\\Mail\\Mail give #1124

Closed
@AdamDomafoldi

Description

@AdamDomafoldi

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions