Both Delivery and Bounce SNS notifications after sending via AWS SES

I have such a really awkward situation, maybe I don't understand how to use these notifications.

I have configured AWS SES to post to a topic after emails have been sent. I have set it to post for Bounce, Complaint and Delivery.

What I do, when I get an SNS notification on my web server, I will look up that post ID in my database and then change its status. For example, if a delivery notification arrives, I change the status of the message to Delivered. If a bounce notification appears, I change the status of the message to Bounce.

However, I now notice that many of these emails send 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" appears first and then "Delivered", my status in my database for that post becomes "Delivered", which I thought was probably misleading.

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

Second question I feel like I misunderstand the shipping notice. I tried reading AWS docs, but to be honest, they weren't the best docs on earth. Can anyone give me a simple, clear explanation for this?

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

Your help is appreciated.

Thank!

-

For your information, I have attached a sample that consists of a set of two 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"
}

      

+3


source to share


1 answer


The nature of the SMTP delivery that SES uses for all outbound delivery (whether you use SMTP or API) is such that both bounces and deliveries sometimes occur on the same message.

To draw a parallel, imagine I ask you to call a company on my behalf and leave a message for Jane Smith, although (unknown to you) there is no person in that company under that name. There will be one of two things:

  • before the end of the call they will tell you: "Sorry, there is none of this name here" or

  • You will leave a message and end the call because the person receiving the message assumes there is someone by that name, or perhaps the name of a former employee that the caller is no longer present.

In the first scenario, if I ask, "did you leave a message for Jane?" you would say no. But in the second scenario, you would say yes.

But ... after you finish the conversation, in the second case, someone from the company will subsequently understand that the message is addressed to an unknown person. If they are polite, they can call you to say, "We cannot deliver your message because none of this name is here."

Now you call me and say, "I could not deliver this message." "Wait, what? You said you already did."

But the reason why you are not actually delivering this message, even though you said it was, is clear enough.

The same problem occurs with email. Perhaps the correct behavior for an inbound mail server is to immediately reject a message that will not be available.

Unfortunately, a huge number of email providers do not validate the email address when presented at the start of an SMTP transaction. Instead, they accept all mail for the domains they need and defer the availability check until they can actively reject the incoming message ... which is necessary for SES to avoid sending a false alarm DSN. By postponing verification, it becomes necessary for the recipient system to actually generate an email to the sender (which turns out to be SES due to the way messages are formatted.) In the absence of genuine bounce, SES first thinks the mail was delivered and then thinks the mail was bounced.

In most cases, the email that returns the SES disclaimer has actually bounced ... regardless of any DSN received. As a rule, the delivery should come first, but this can lead to their problems - although this should be an exception.



For ISP bounces, Amazon SES only reports hard bounces and soft bounces that will no longer be repeated by Amazon's ASES. In these cases, your recipient has not received your email and ASES Amazon will not try to resend it.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/notifications.html

It's simple enough ... But of course there is an annoying exception:

You are notified of Out of Office Messages (OOTO) using the same method as bounces, although they are not counted in your bounce statistics.

Answers outside the office, on the wire, are very much like bounces. Presumably when SES can't figure out the best bounce type to report, based on plotting the bounce message sent back after the destination has apparently already received your message ... they use what you see in your example:

        "bounceSubType": "General",
        "bounceType": "Transient",

      

See http://docs.aws.amazon.com/ses/latest/DeveloperGuide/notification-contents.html#bounce-types for possible combinations.

Your best approach is to probably keep all the answers in case this turns out to be a less accurate estimate, and treat the Transient / General disclaimer as a warning to leave the office.

Other Transient subtypes can be interpreted as someone you could successfully send to in the future, while persistent subtypes are addresses that you should avoid sending as the address is considered permanently unavailable.

Except outside the office, bounces should (no misconfiguration on the recipient side) be a reliable enough indicator for you that this particular message did not get through.

+6


source







All Articles