Sendgrid Bounce Notifications in Kentico

Posted: 6/4/2019 1:21:40 PM by Chris Bass | with 0 comments

So, SendGrid works really well in basic sense with Kentico. You go into your Kentico settings, set smtp.sendgrid.com as your mail client, and proceed to use Kentico to send your emails, through SendGrid.
This works great, until you start using Email Marketing - With Email Marketing, one of the things you probably want to be able to see in Kentico is bounce reports, and therein lies the issue.

So, with Kentico's emails, Kentico sends three custom headers, each starting wtih 'X-CMS-': IssueID, SubscriberID, and ContactID. These three headers specify keys related to the bounce, so Kentico can track which email was actually bounced. If Kentico was directly receiving bounces returned from its emails (which it allows through a POP3 address), it would sniff those headers out and be able to mark which person bounced on which email. 

SendGrid, on its end, offers three ways to give Kentico information about the bounces.

  1. A REST API that lets you query the bounces
  2. A forwarding email address for it to forward bounce notifications to.
  3. An "Event Notification" system, that does an *outgoing* notification to an endpoint, which you can configure, conveniently, to fire on bounced email. 

The problem is, none of these solutions actually include the bounced email headers that Kentico sent along, those 'X-CMS-' headers. Even if I ignore Kentico's POP3 endpoint and just use the API to submit a bounce directly to Kentico, their methods require that ID to sync it up. Checking in with SendGrid support I confirmed that they do not forward the headers.

Those headers are just a shortcut used for the Check Bounced Emails scheduled task, in the class CMS.Newsletters.BounceChecker. https://docs.kentico.com/k12/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-email-marketing/configuring-bounced-email-monitoring

Since it's a scheduled task, you can just create your own, if you want - in the end, all it does is update SubscriberInfo.SubscriberBounces, ContactInfoProvider.AddContactBounce(contactID), and IssueInfoProvider.IssueBounces. So if you want to use one or more of those, you can figure out the contact some other way (I was able to search for contact/subscriber by email, but SendGrid's Event Notification just reports the bounces, not what email they were associated with - so I was unable to set the Issue-based bounces). Just note that unless you set up a pop3 address (even if it's a dummy one), you'll still get the Bounced Email warning on the Email Marketing pages, but your reports should work properly in any case.

 

 

Comments
Blog post currently doesn't have any comments.
 Security code