i will be receiving JSON POST as mentioned on this web page

https://sendgrid.com/blog/sendgrids-parse-api-parsing-incoming-email-is-now-faster-and-easier/

how do my application receive this request and process furthur??

Recommended Answers

All 3 Replies

Hi,

you have to set a callback URL to receive the POST requests, from Parse API documentation:

The Parse API will POST the parsed email to a URL that you specify. If a POST is unsuccessful, SendGrid automatically queues and retries any POSTs that respond with a 4XX or 5XX status. This prevents data loss for customers who have misconfigured their website or POST URL.

More here:

i dont understand meaning of webhooks and callback url..

An hook is a technique to extend or modify the behaviour of an event in a program. A webhook is the same but related to web events.

A callback url is part of a webhook: it's used to allow a remote server to send an asynchronous response to a previuos request or simply to send data to your server.

In practice you are allowing a remote server (SendGrid) to perform a POST request to your server and let you receive incoming emails. To very simplify the flow it's like pointing a form to a script:

<form method="post" action="/path/to/script.php">

The only differences are that:

  1. the action is defined in the SendGrid interface and not into your website;
  2. and the path will include your domain: http://website.tld/path/to/script.php

Note that SendGrid requires also that you fix your MX record, as explained in the first link.

The content of the callback file (script.php) will be the same that you would write for a form used in your website, for example:

<?php

    if($_POST)
    {
        # code here
    }

The request body received by $_POST will be composed by the keywords defined in the setup table:

So: $_POST['headers'], $_POST['text'], $_POST['html'], $_POST['from'] and so on.

Hope it helped you to understand it better, otherwise ask to SendGrid support or wait for other replies. Bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.