-1

Our team recently used SendGrid to build a new email service. From the standpoint of testing, we have a use case to determine whether or not the email was sent.

We discovered inbound parse while seeking a solution. This inbound parsing takes incoming emails and redirects them to a webhook URL. There are some problem statements that prevent us from completing validation with inbound parsing, and there are some access reasons that prevent us from doing so.

I'd like to know if there is another method to accomplish this.

philnash
  • 70,667
  • 10
  • 60
  • 88
Kaushik
  • 89
  • 1
  • 12

1 Answers1

0

I think you're looking for the Event Webhook rather than the Inbound Parse Webhook. The Event Webhook will batch up and send events based on the emails you've sent, in this case when you receive the "delivered" event it tells you that the email has been successfully delivered to the receiving server.

There are other delivery events that are useful too, like "deferred", "bounced", or "blocked". And other events, like engagement events such as "open" or "click".

philnash
  • 70,667
  • 10
  • 60
  • 88
  • These Event Webhooks essentially assist us in ensuring the email status based on events such as Processed, Dropped, and so on.My use case is that, as I mentioned before, we leverage Sendgrid and created a new service for emails We send emails from one service, and they are routed through new email services. Assume the email is sent with the subject "hello world" and the email content is generated at run time. The above Event webhook will be beneficial to verify whether or not an email has been delivered, but my use case is to check email deliverability as well as email contents. – Kaushik Mar 07 '22 at 04:43
  • The event webhook tells you when those events have happened, yes. What are you looking for? – philnash Mar 07 '22 at 04:44
  • updated my comments – Kaushik Mar 07 '22 at 04:50
  • 1
    Are you trying to perform this use case in a test environment? Or are you looking to validate the contents of all the emails that you send in production? And what do you mean by "check email deliverability"? Are you looking to check that emails arrived at the server you sent them to? Or some other meaning of deliverability? – philnash Mar 07 '22 at 04:53
  • So basically the expectation is to ensure whether the email is delivered to the recipient with appropriate subject and mail content. This is done in the test environment – Kaushik Mar 07 '22 at 05:12
  • Oh, in that case you can use the Inbound Parse webhook if you send the email to your own domain in test. When the inbound parse webhook fires that means that SendGrid received the incoming email and you can then inspect the contents of the sent email. Though personally when I am testing, I try not to test 3rd party services, as it can make for slow and potentially brittle tests. I prefer to mock out a service like this and ensure that I am sending the correct content/email addresses to the API, but not actually make the call. – philnash Mar 07 '22 at 05:15
  • Yeah, as you said testing the subject and content in Integration with mock service is a good approach. Coming to the email delivery part from event webhook. Currently we use 1 sendgrid account for dev,qa and prod environment. If i enable Event Webhook for delivered, all the prod emails will be delivered to webhook url, which can be a possible security concern. Is there an option where i can filter emails that has specific to address or filter with certain subject to be delivered in URL ? – Kaushik Mar 07 '22 at 06:50
  • I think you need to look into [subusers](https://docs.sendgrid.com/ui/account-and-settings/subusers) so that you can separate this data. Different subusers can set different webhooks for their email processing. – philnash Mar 07 '22 at 06:56
  • Is there an option where i can send the webhook event to a gcp pubsub ? – Kaushik Mar 07 '22 at 10:10
  • I haven’t used GCP pubsub. A quick search tells me that you probably can’t just set the webhook to POST straight to pubsub. Likely the best thing is to set up a Cloud Function to receive the webhook, and then send it into pubsub. – philnash Mar 07 '22 at 10:18
  • Thanks for your suggestions, while exploring more documentation, came to know about filter all messages API https://docs.sendgrid.com/api-reference/e-mail-activity/filter-all-messages This seems to be a good fit for us, but we have to do some sort of implementation – Kaushik Mar 07 '22 at 13:29