简体   繁体   中英

Retrieving sending statistics applicable to Amazon SES service

I am writing Java app which sends email via Amazon SES service, and that works fine. But now I need to retrieve email sending statistics as granural as per email ID basis.

So, I use CloudWatch and pass the notifications to SNS . Yet, I cannot infer away how to get the statistics as per explicit request to the Web service. The SNS endpoints are able to dispatch the data as on needing basis. When I want to make explicit request from my app on service for stats.

The S3 service is for storage. Do I need to store stats somehow on it, so that later I can query it? Any resolutions and details are appretiated?

Hi For your requirement as per my understanding AWS Dynamo DB is the best way. AWS Dynamo DB is a No sql related DB. After sending email you can store the result (emailId, if you want time ect..) into Dynamo DB by using SNS, or nay lambda functions. You can fire a query to dynamo DB to get the statistics.

If you want to go with S3 bucket way, you have a maintain one json file, and each time need to overwrite that file.

Well, this is the way I got the sending stats. When it comes to Amazon SES , it gives you very limited sending statistics; not pointing to particular sent email.

Then when it comes to Amazon Cloudwatch , it gives you very similar statistics as the SES, is that it gives you a chance to make the stats dates appear precise to the extend of minutes. Meaning that if you know when you sent the email, via SES, by storing it on DB, you can estimate which stat belongs to which email.

Then you can use the Amazon Firehose combined with Amazon S3 . This is where I landed. The Firehose is a stream which pushes statistics on the S3 storage. The SES provides the configuration set which lets you attach it. The S3 stores anything you like, including email sending statistics. You can have up to 5 stats:

  • Send
  • Delivered
  • Bounce
  • Complaint
  • Reject

The stats are stored in files which you can access and read by using Amazon's SDK pertaining to Java language . The way to query in Java

What you get then is JSON file of email sending statistics, eg,

    {
   "eventType":"Bounce",
   "bounce":{
      "bounceType":"Permanent",
      "bounceSubType":"General",
      "bouncedRecipients":[
         {
            "emailAddress":"recipient@example.com",
            "action":"failed",
            "status":"5.1.1",
            "diagnosticCode":"smtp; 550 5.1.1 user unknown"
         }
      ],
      "timestamp":"2016-10-14T05:02:52.574Z",
      "feedbackId":"EXAMPLE7c1923f27-ab0c24cb-5d9f-4e77-99b8-85e4cb3a33bb-000000",
      "reportingMTA":"dsn; ses-example.com"
   },
   "mail":{
      "timestamp":"2016-10-14T05:02:16.645Z",
      "source":"sender@example.com",
      "sourceArn":"arn:aws:ses:us-east-1:123456789012:identity/sender@example.com",
      "sendingAccountId":"123456789012",
      "messageId":"EXAMPLE7c191be45-e9aedb9a-02f9-4d12-a87d-dd0099a07f8a-000000",
      "destination":[
         "recipient@example.com"
      ],
      "headersTruncated":false,
      "headers":[
         {
            "name":"From",
            "value":"sender@example.com"
         },
         {
            "name":"To",
            "value":"recipient@example.com"
         },
         {
            "name":"Subject",
            "value":"Email Subject"
         },
         {
            "name":"MIME-Version",
            "value":"1.0"
         },
         {
            "name":"Content-Type",
            "value":"multipart/mixed;  boundary=\"----=_Part_0_716996660.1476421336341\""
         },
         {
            "name":"X-SES-MESSAGE-TAGS",
            "value":"myCustomTag1=myCustomTagValue1, myCustomTag2=myCustomTagValue2"
         }
      ],
      "commonHeaders":{
         "from":[
            "sender@example.com"
         ],
         "to":[
            "recipient@example.com"
         ],
         "messageId":"EXAMPLE7c191be45-e9aedb9a-02f9-4d12-a87d-dd0099a07f8a-000000",
         "subject":"Email Subject"
      },
      "tags":{
         "ses:configuration-set":[
            "my-configuration-set"
         ],
         "ses:source-ip":[
            "192.0.2.0"
         ],
         "ses:from-domain":[
            "example.com"
         ],
         "ses:caller-identity":[
            "ses_user"
         ],
         "myCustomTag1":[
            "myCustomTagValue1"
         ],
         "myCustomTag2":[
            "myCustomTagValue2"
         ]
      }
   }
}

That is about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM