phpparsingwebhookssendgridinbound

How to get data from Sendgrid Inbound Parse Webhook?


Goal
Process data from Sendgrid Inbound Parse Webhook without parsing the mail inside our application.

Problem
The multipart/from-data seems to be empty/corrupt or wrongly accessed inside the application.

Description
A few months ago we set up the Sendgrid Inbound Parse Webhook with our MX records and everything worked on the dev environment with ngrok. The parsed email reached our application (PHP 8) and could be processed. We could access the parameters TO, FROM, TEXT, HTML and we also got the attachments.

Yesterday we detect, that the emails pushed by the webhook couldn't be processed in the application anymore. The formdata seems to be empty or corrupt. In ngrok we couldn't see any data in the summary. The only line is "9324 bytes multipart/form-data; boundary=xYzZY".
enter image description here
enter image description here

When we replay the post with ngrok and set the XDEBUG_SESSION for debugging, we could see, that the formdata is empty/missing.

enter image description here

A few months ago and when we now enable the "Send Raw" option, we see the whole payload in the ngrok summary as it is described here: https://sendgrid.com/docs/for-developers/parsing-email/setting-up-the-inbound-parse-webhook/ under "Example Raw Payload". So when we enable "Send Raw" we can process the data inside our application but therefore we have to rewright a few things in our code for parsing the raw data by our own. We want to avoid this especially because it worked already a few months ago.

Maybe, anybody has an idea and can help out or faced this problem already?


Solution

  • Found the answer finally:

    If the body of the request is too big or have attachments, ngrok doesn't post it, if you hit the replay button, because it doesn't exist any more. Seems, that ngrok doesn't cache it, if it is too big.