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.
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 chapter4.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...