lundi 6 juillet 2015

Both "Delivery" and "Bounce" SNS Notifications after sending via AWS SES

I have these really awkward situation, perhaps I'm misunderstanding the use of these notifications.

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.

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".

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.

So if "Bounce" arrives first, and then "Delivered", my status in my database for this message becomes "Delivered", which I thought is probably misleading.

First question How do I check the sequence of these notifications?

Second question 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?

Third question Am I even handling these notifications correctly? Or is there a better way?

Your help is appreciated.

Thanks!

--

For your information, I've attached a sample, which consists of a set of 2 notifications. One bounce, and one delivery.

{
    "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": "<no-reply@bs.com.hk>",
            "messageId": "xxxxx
            "destination": [
                "<ooto@simulator.amazonses.com>"
            ]
        },
        "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": [
                "<ooto@simulator.amazonses.com>"
            ],
            "source": "<no-reply@bs.com.hk>"
        }
    },
    "Timestamp": "2015-07-05T19:30:41.315Z",
    "SignatureVersion": "1",
    "Signature": "xxxxx",
    "SigningCertURL": "xxxxx",
    "UnsubscribeURL": "xxxxx"
}




Aucun commentaire:

Enregistrer un commentaire