Search code examples
phpemailcakephpsendgridngrok

Proper approach to test inbound emails on localhost


I am currently working on a legacy CakePHP application that needs to to able to receive and parse emails using Sendgrid Webhooks. My team does it's development locally on our laptops and utilizes web servers for testing.

This feature should be able to receive an email from from an email client (gmail, etc.), parse it out and create items in the database based off of the email's contents. I am wondering what the most strait forward approach would be to test something like this locally while in development or if I am better off developing this on one of our servers in AWS? I am currently looking at Ngrok following this tutorial, but it is a bit dated and I wonder if there is a better way to handle this.

Also looking at using Mail Mine Parser for PHP, on the application side. If you happen to know of something better I would certainly be interested to know about it.

Thanks in advance for any feedback on the subject!


Solution

  • Handled a similar task using sengrid inbound webhooks and ngrok. The latter allows you to expose a public url on your local laptop/machine where sendgrid can send incoming emails. Please check:

    https://sendgrid.com/docs/for-developers/parsing-email/setting-up-the-inbound-parse-webhook

    https://ngrok.com

    I would suggest you test your webhook using ngrok before you set-up your own inbound webhook server.