0
votes

I am using Sendgrid for mass-mailing. I use multiple categories for different emails, after sending the email I want to get all the responses of the email which is sent at Sendgrid side through the API used for sending the mail.

I am getting response of opening the email but exactly which email is opened that I'm not getting. I want to keep track of each email; is there any need to create common parameters on our server side?

2
By "get all the responses of the email", do you mean SMTP server responses? Message are likely to be added to a queue, so if Sendgrid do offer this (and I expect they would) you'll not get the results synchronously - you'll need to make another API call to check how many times they've tried and what responses they got each time. - halfer

2 Answers

0
votes

To view stats on individual emails, you can use the Email Activity page, but that only gives you a week's worth of data due to log rotation. There is currently no pull API for this data.

To gather this data programmatically and store it, SendGrid provides an Event Webhook that will push events to a URL you define in near real-time.

If you still want to associate custom parameters with individual emails, that can be done using Unique Arguments

0
votes

Yes, there is a way to do this by using unigue_args parameter. A built-in option would be to use category parameter. You can then add this tag when sending out the email via server side.

<php? $hdr->setCategory('Bounce Notice'); ?>

This would be the returned format.

{
  "category": "Example Category"
}

I have been building [a repo][2] with a working example of the event notification API which stores information into a local databae. This process will log any of the following: delivered, bounced, delayed, clicked, etc. SendGrid will post events to a script of your choosing via the Apps section in your account.

GitHub repo of Sendgrid Event Notifications