Handling inbound e-mail parsing in yii2 framework

While there are many different ways of handling inbound e-mail parsing, one of the easiest ways is to send that e-mail to a third party, who will then parse the contents for us, and send it as a $_POST request to an open endpoint in our application. This is exactly what SendGrid will do for us. However, before we can start using SendGrid, we need to make a couple of changes to our DNS server for our domain and to our SendGrid account.

Sending e-mails to SendGrid

To direct our e-mails to SendGrid in order to pass, we first need to make a change to our DNS settings. In keeping with our example domain dunebook.example.com, we first need to log in to our DNS host and add a new Mail Exchange (MX) record to our subdomain. Specifically, we need to add an MX record with a priority of 10 to mx.sendgrid.net. In most DNS systems, that record would look as follows:

chapter4     IN     MX     10     mx.sendgrid.net.

Alternatively, if you’re using a service like CloudFlare to handle your DNS, your entry may look as follows:

Sending e-mails to SendGrid

Note

Depending upon your DNS provider, DNS settings may take up to 24 to 48 hours to propagate. Before leaving this step, verify that the MX record was added and propagated using either a command-line tool, such as a DIG or a free, online web tool.

Adjusting SendGrid Parse settings

Once you’ve updated your DNS settings, you then need to update your SendGrid Parse API settings so that SendGrid knows where to send your e-mails. Navigate to www.sendgrid.com/developer/reply, and then fill in the parse settings page as follows and submit the record:

Once you’ve added the record, you should see confirmation at the bottom of the page. Once this has been completed, you can now send e-mails to [email protected], and SendGrid will parse it and forward it onto your actionEmailUpdate() method of our IssueController.

Note

You can read more about the SendGrid Parse API webhook at http://sendgrid.com/docs/API_Reference/Webhooks/parse.html.

 

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares