minou
minou

Reputation: 16553

Single SNS notification for multiple recipients

I'm trying to understand how SNS will transmit a single notification for multiple recipients. The Amazon SES docs state:

For a given notification type, you might receive one Amazon SNS notification for multiple recipients, or you might receive a single Amazon SNS notification per recipient.

but does not give an example.

Let's use an abbreviated delivery notification as an example:

{
  "Message": {
    "notificationType":"Delivery",
    "mail":{
      "timestamp":"2017-06-22T17:15:53.980Z",
      "messageId":"123",
      "destination":["[email protected]"],
      },
    "delivery":{
      "timestamp":"2017-06-22T17:15:54.873Z", 
      "recipients":["[email protected]"],
    },
  }, 
  "Type": "Notification"
}

How does Amazon provide info for multiple recipients in a single notification? The structure of the JSON object seems specific to a single event and does not seem adaptable for providing info about multiple recipients. For example, there is only one "delivery" with one "timestamp". How could you report deliveries to two people?

The bounce and complaint notifications also don't seem compatible with providing info for multiple recipients.

Upvotes: 1

Views: 2466

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 178956

The structure of the JSON object seems specific to a single event

Right. This only happens when multiple recipients are involved in a single event.

The only way more than one recipient could logically be in one notification (with one timestamp) is if their mailboxes are handled by the same mail exchanger (MX).

A low-level understanding of SMTP's wire protocol makes this clearer. For each SMTP transaction, the SMTP protocol requires the sending server to first identify the sender, then one or more recipients, and then transmit the message payload. When SES is delivering a single message to multiple recipients whose email addresses map to the same MX, it may choose to avoid redundant transmission of exactly the same data by specifying multiple recipients in a single transaction... in which case, the multiple recipients would all have received the message simultaneously.

The same holds true for a bounce. If both recipients were rejected by the destination server, there's a simultaneous bounce event.

Complaints are different, but the idea is the same. If the destination system defers the individual user complaints and pushes them back to SES together, that should be a possible case with multple recipients. This one seems less likely.

But if you sent a single message to a gmail address and a hotmail address, this would never happen since those destinations have no common infrastructure.

The data structures, of course, do accommodate multiple recipients, with destination and recipients both being arrays.

Upvotes: 3

Related Questions