AWS SDK for Go
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Getting Amazon SES Statistics

The following example demonstrates how to use the AWS SDK for Go to get statistics about Amazon SES. Use this information to avoid damaging your reputation when emails are bounced or rejected.

package main import ( //go get -u "" "" "" "fmt" ) func main() { // Initialize a session that the SDK uses to load // credentials from the shared credentials file ~/.aws/credentials // and configuration from the shared configuration file ~/.aws/config. sess := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, })) // Create an SES session. svc := ses.New(sess) // Attempt to send the email. result, err := svc.GetSendStatistics(nil) // Display any error message if err != nil { fmt.Println(err.Error()) return } dps := result.SendDataPoints fmt.Println("Got", len(dps), "datapoints") fmt.Println("") for _, dp := range dps { fmt.Println("Timestamp: ", dp.Timestamp) fmt.Println("Attempts: ", aws.Int64Value(dp.DeliveryAttempts)) fmt.Println("Bounces: ", aws.Int64Value(dp.Bounces)) fmt.Println("Complaints:", aws.Int64Value(dp.Complaints)) fmt.Println("Rejects: ", aws.Int64Value(dp.Rejects)) fmt.Println("") } }

See the complete example on GitHub.