title: Both "Delivery" and "Bounce" SNS Notifications after sending via AWS SES
body: <p>I have these really awkward situation, perhaps I'm misunderstanding the use of these notifications.</p>
  
  <p>I've set up AWS SES to publish to a topic after sending emails out.  I've set it to publish for Bounce, Complaint, and Delivery.</p>
  
  <p>What I do is, when I receive an SNS notification on my web server, I will look up that message id in my database, and then change its status.  For instance, if delivery notification arrives, I change the message status to "Delivered".  If bounce notification arrives, I change the message status to "Bounced".</p>
  
  <p>However, now I notice that many of these emails are sending me both notifications, and they are not always in a specific order.  Sometimes one comes earlier than the other, and sometimes vice-versa.</p>
  
  <p>So if "Bounce" arrives first, and then "Delivered", my status in my database for this message becomes "Delivered", which I thought is probably misleading.</p>
  
  <p><strong>First question</strong>
  How do I check the sequence of these notifications?</p>
  
  <p><strong>Second question</strong>
  I feel that I'm misunderstanding the "Delivery" notification.  I've tried reading the AWS docs, but to be honest, they weren't the best docs on Earth.  Can anyone give me a simple, clear explanation on this?</p>
  
  <p><strong>Third question</strong>
  Am I even handling these notifications correctly?  Or is there a better way?</p>
  
  <p>Your help is appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>--</p>
  
  <p>For your information, I've attached a sample, which consists of a set of 2 notifications.  One bounce, and one delivery.</p>
  
  <pre><code>{
      "Type": "Notification",
      "MessageId": "2efb9ee6-6bd5-576d-b80d-d0f5e3f44f23",
      "TopicArn": "arn:aws:sns:us-east-1:#####:ses_beamstyle_com_hk",
      "Message": {
          "notificationType": "Delivery",
          "mail": {
              "timestamp": "2015-07-05T19:30:40.441Z",
              "source": "&lt;no-reply@bs.com.hk&gt;",
              "messageId": "xxxxx
              "destination": [
                  "&lt;ooto@simulator.amazonses.com&gt;"
              ]
          },
          "delivery": {
              "timestamp": "2015-07-05T19:30:41.101Z",
              "processingTimeMillis": 660,
              "recipients": [
                  "ooto@simulator.amazonses.com"
              ],
              "smtpResponse": "250 2.6.0 Message received",
              "reportingMTA": "a9-140.smtp-out.amazonses.com"
          }
      },
      "Timestamp": "2015-07-05T19:30:41.179Z",
      "SignatureVersion": "1",
      "Signature": "xxxxx",
      "SigningCertURL": "xxxxx",
      "UnsubscribeURL": "xxxxx"
  }
  
  
  
  
  
  {
      "Type": "Notification",
      "MessageId": "b6e8bb7d-4e73-52ae-b690-f56ec6527ce5",
      "TopicArn": "arn:aws:sns:us-east-1:#####:ses_beamstyle_com_hk",
      "Message": {
          "notificationType": "Bounce",
          "bounce": {
              "bounceSubType": "General",
              "bounceType": "Transient",
              "bouncedRecipients": [
                  {
                      "emailAddress": "ooto@simulator.amazonses.com"
                  }
              ],
              "timestamp": "2015-07-05T19:30:41.000Z",
              "feedbackId": "xxxxx"
          },
          "mail": {
              "timestamp": "2015-07-05T19:30:40.000Z",
              "messageId": "xxxxx",
              "destination": [
                  "&lt;ooto@simulator.amazonses.com&gt;"
              ],
              "source": "&lt;no-reply@bs.com.hk&gt;"
          }
      },
      "Timestamp": "2015-07-05T19:30:41.315Z",
      "SignatureVersion": "1",
      "Signature": "xxxxx",
      "SigningCertURL": "xxxxx",
      "UnsubscribeURL": "xxxxx"
  }
  </code></pre>