Setup integration: Amazon Simple Email Service (SES) Event

You need to setup an AWS SNS HTTPS endpoint for this integration!

This integration requires marbot  plus

Amazon Simple Email Service (SES) is an email sending service to send marketing, notification, and transactional emails. You can use the SMTP interface or one of the AWS SDKs to integrate Amazon SES directly into your existing applications. SES can send events to SNS. Supported event types are:

  • Send: SES is processing the email
  • Reject: the email contained a virus
  • Bounce: e.g., the recipient does not exist
  • Complaint: the recipient marked the email as spam
  • Delivery: the email was delivered
  • Open: the recipient opened the email in his or her email client
  • Click: the recipient clicked one or more links contained in the email
  • Rendering Failure: the email was not sent because of a template rendering issue
    You can select the events that you want to receive.

Monitoring email bounces

If you send out emails, the SMTP server on the other end may reject the message. This could be caused because the recipient does not exist or the inbox of the recipient is full. You may want to know about this event to clean up your database.

Before you can start to set up SES Events, you have to make one change to the SNS topic endpoint that is required for this integration. You have to allow SES Events to send messages to your topic.

Allowing AWS to send messages to your topic

  1. Visit https://console.aws.amazon.com/sns/?region=us-east-1
  2. Click on the Topics link on the left
  3. Select the topic that you created for marbot
  4. Click on the Actions button, where you click on the Edit topic policy link.
    Edit SNS topic policy
  5. Select the Advanced view tab

If this is the first time you edit the SNS topic policy, you should see a default entry like this:

{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
[...TRUNCATED...]
}
]
}

You have to add an entry to the Statement array:

{
"Sid": "AWSSESEvents",
"Effect": "Allow",
"Principal": {
"Service": "ses.amazonaws.com"
},
"Action": "sns:Publish",
"Resource": "ARN",
"Condition": {
"StringEquals": {
"AWS:Referer": "ACCOUNT_ID"
}
}
}
  1. Replace ARN with your SNS topic ARN that you created for marbot.
  2. Replace ACCOUNT_ID with your AWS Account ID.
  3. Click on the Update policy button to save the policy.

Save SNS topic policy

Now, AWS is allowed to send messages to your topic.

Enable SES events

  1. Visit https://console.aws.amazon.com/ses/home?region=us-east-1
  2. Click on the Configuration Sets link on the left
  3. Click on the Create Configuration Set button
    Enabling SES events
  4. Set Configuration Set Name to marbot
  5. Save by clicking the Create Configuration Set button.
    Enabling SES events
  6. Click on the newly created configuration set
    Enabling SES events
  7. Set Add Destination to SNS
    Enabling SES events
  8. Set Name to marbot
  9. Enable Event type Bounce
  10. Set Topic to marbot or your other SNS topic name
  11. Save by clicking the Save button.
    Enabling SES events

Sample Alert

To simulate a delivery failure, you have to send an email using the AWS CLI or one of the AWS SDKs. The following command uses the AWS CLI and can be executed in your terminal. Replace domain.com with your SES domain.

aws ses send-email --configuration-set-name marbot --from "test@domain.com" --to "notexistent@domain.com" --subject test --text text

The configuration-set-name parameter specifies that the email is sent using the newly created Configuration Set marbot.

You should receive an alert in Slack:

AWS SES Event Alert