502 Bad Gateway - Sendgrid PHP Mail Issue 502 Bad Gateway - Sendgrid PHP Mail Issue nginx nginx

502 Bad Gateway - Sendgrid PHP Mail Issue


There is some weird issue with SendGrid. Sometimes, the API gets soft deleted automatically in the backend. To make the code work, I had to create a new API key and retry. And the solution worked.

Note - Some issues in GitHub instructed to initialize a constructor with a from address, but that was not the actual issue. The workaround is to create a new API key in the dashboard till SendGrid investigates why the API is soft deleted so that the API call returns an error.