Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sendgrid php library incompatible with PHP 8.1 #1072

Open
charliepfm opened this issue Dec 14, 2021 · 4 comments
Open

Sendgrid php library incompatible with PHP 8.1 #1072

charliepfm opened this issue Dec 14, 2021 · 4 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@charliepfm
Copy link

Summary

Heroku Platform with SendGrid provisioned. Emails have been going out fine for many months. Heroku pushed PHP v8.1 into all Dynos (instances) on Dec 10, 2021. A release of our application was published today (Dec 14) and now all attempts to send emails with the SendGrid API fail.

Steps to Reproduce

  1. Use existing code to attempt to send a simple email with SendGrid with a PHP 8.1 environment
  2. The error message received is as follows:
    "Return type of SendGrid\Mail\Mail::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange (and so on)

Code Snippet

  function sendvcodeemail ($thevalue, $destemail) {
    $email = new \SendGrid\Mail\Mail(); 
    $email->setFrom(<specific an email address that has been verified>, <some name string>);
    $email->setSubject("Verification code for <application>");
    $email->addTo($destemail, "User");
    $cmsg = "Your verification code is " . $thevalue . PHP_EOL . 
            "This code is only valid for a few minutes, please use it quickly";
    $email->addContent("text/plain", $cmsg);
    $sendgrid = new \SendGrid(getenv('SENDGRID_APIKEY'));
    try {
        $response = $sendgrid->send($email);
        $_SESSION['justsomething'] = $response;
    } catch (Exception $e) {
        $_SESSION['justsomething'] = 'there was an error sending email';
    };
  };

sendvcodeemail("123456","<a valid email destination>");

Technical details:

sendgrid-php version: 7.11 (using composer.json -> require: {"sendgrid/sendgrid": "^7", ....
php version: According to build log on Heroku deploy - version 8.1

@jonathonbyrdziak
Copy link

following. +1

@ncovercash
Copy link

Here are the specific lines/files with these errors:

Deprecated: Return type of SendGrid\Mail\Mail::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/cloud-screen.com/src/vendor/sendgrid/sendgrid/lib/mail/Mail.php on line 1837

Deprecated: Return type of SendGrid\Mail\Personalization::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/cloud-screen.com/src/vendor/sendgrid/sendgrid/lib/mail/Personalization.php on line 280

Deprecated: Return type of SendGrid\Mail\EmailAddress::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/cloud-screen.com/src/vendor/sendgrid/sendgrid/lib/mail/EmailAddress.php on line 183

Deprecated: Return type of SendGrid\Mail\Subject::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/cloud-screen.com/src/vendor/sendgrid/sendgrid/lib/mail/Subject.php on line 63

Deprecated: Return type of SendGrid\Mail\Content::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/cloud-screen.com/src/vendor/sendgrid/sendgrid/lib/mail/Content.php on line 106

@ncovercash
Copy link

ncovercash commented Jan 13, 2022

It looks like #1066 should have fixed this (effective as of v7.11.1), however, it does not work on my tests.

@childish-sambino
Copy link
Contributor

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@childish-sambino childish-sambino added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap labels Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

4 participants