> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dittofeed.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon SES Integration

Dittofeed can integrate with Amazon SES to send emails.

## Integration Instructions

### Prerequisites

Follow the instructions in the [AWS documentation](https://docs.aws.amazon.com/ses/latest/dg/setting-up.html) to setup an
AWS and SES account if you do not already have an account.

Verify a domain name and/or an email address in order to test your account setup.

### Create credentials

You'll need to create an IAM user and access tokens for Dittofeed to authenticate with AWS.

First, create a policy to attach to the IAM user we'll create in a moment.

Visit the IAM section of the AWS console and Click "Policies" then "Create Policy"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-specifypermissions.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=cb295d6fc08dbf284fc0daea20d92856" alt="AmazonSES Specify Permissions" width="1226" height="1087" data-path="images/amazonses-specifypermissions.png" />
</Frame>

Switch to the JSON policy editor and paste the policy from below.

```
{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Effect": "Allow",
			"Action": [
				"ses:SendRawEmail",
				"ses:SendEmail"
			],
			"Resource": "*"
		}
	]
}
```

<Warning>
  Note: It is good practice to limit access to a specific set of identity or
  configuration set. Edit the "Resource" property of the policy to enforce this
  restriction.
</Warning>

Click "Next"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-policy-details.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=c20bce6a5c5952edb144ebd01b6c13b2" alt="AmazonSES Policy Details" width="2418" height="2162" data-path="images/amazonses-policy-details.png" />
</Frame>

Give the policy a name (e.g. "SESSendEmail") and click "Create Policy".

Next, we'll create the IAM user. Visit the IAM section of the AWS console and Click "Users" then "Create User".

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-userdetails.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=df40b4ab9126c1ec98e98e3cc3189c9d" alt="AmazonSES User details" width="2418" height="2172" data-path="images/amazonses-userdetails.png" />
</Frame>

Enter a username and click "Next". (Leave "access to AWS Management Console unchecked")

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-setpermissions.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=91f91191215109711c4b921b4e5ba2cd" alt="AmazonSES Set Permissions" width="1226" height="1087" data-path="images/amazonses-setpermissions.png" />
</Frame>

Choose the option to "Attach Policies Directly" and search for your policy name. Check the box next to the policy you just created and click "Next"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-reviewandcreate.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=dbf5c178026966a6820e116fbe11789c" alt="AmazonSES Review and create user" width="1226" height="1087" data-path="images/amazonses-reviewandcreate.png" />
</Frame>

Click "Create User". You'll be returned to the list of users. Click to view details on your newly created user.

Click the tab for "Security Credentials" then click "Create access key"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-accesskey-best.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=47f79cf5121a8f6316c7ea6963759637" alt="AmazonSES access key best practice" width="1209" height="1109" data-path="images/amazonses-accesskey-best.png" />
</Frame>

Long lived access keys are generally not considered the best practice, however for our purposes this is an acceptable,
strongly limited use.

Select "Third-party service" and check the box that you understand and want to create an access key. Click "Next"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-tokendescription.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=dcf2cc3ade6dccf42a4a70b34654c174" alt="AmazonSES token description tag" width="1226" height="1087" data-path="images/amazonses-tokendescription.png" />
</Frame>

Enter a description for the access key and click "Create Access Key"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-accesskey-show.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=7aac22b39a94d6619589c2ccf1ba55c8" alt="AmazonSES save access key and secret" width="1226" height="1087" data-path="images/amazonses-accesskey-show.png" />
</Frame>

Copy the `access key` and `secret access key`. (Click "Show" to display it).

[//]: # "TODO: Need an image of the SES section in dittofeed"

Enter the access key, secret access key, and region into the appropriate fields in Dittofeed.

### Setting up event forwarding

Event forwarding allows Amazon SES to foward bounce, delivery, etc notifications to Dittofeed for tracking.

Go to the SES section of the AWS console and click "Configuration Sets" on the sidebar.

When you setup your SES account, an initial configuration set should have been created for you (usually named `my-first-configuration-set`).
Click to open this configuration set.

(If a configuration set was not created, you'll need to create one before proceeding)

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-eventdestinations.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=7a6b6bbd9b2ab1bb427503a27e4cb103" alt="AmazonSES event destinations" width="1226" height="1087" data-path="images/amazonses-eventdestinations.png" />
</Frame>

Click the "Event Destinations" tab and "Add Destination"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-eventtypes.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=a2d046e1b2eb1dffa9b85082702495fd" alt="AmazonSES event types" width="1209" height="1124" data-path="images/amazonses-eventtypes.png" />
</Frame>

Check the following event types:

* Rejects
* Deliveries
* Hard Bounces
* Complaints
* Opens
* Clicks

Click "Next"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-specifydestination.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=40ca3be6adc90e89fc64ec7a3a1260a9" alt="AmazonSES event destination" width="1209" height="1124" data-path="images/amazonses-specifydestination.png" />
</Frame>

Select "Amazon SNS" for the destination type and enter a name for this destination.

Make sure "Enabled" is checked.

Click "Create SNS topic" in the next section.

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-createsnstopic.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=8f3213b5f7e4758ed37280a2a0713de1" alt="AmazonSES create SNS topic" width="1226" height="1087" data-path="images/amazonses-createsnstopic.png" />
</Frame>

Enter a topic name and display name. Click "Create Topic"

The new topic should be filled in on the destination screen. Click "Next"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-destinationreview.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=8053610c0415ff2d3882052a84024d8f" alt="AmazonSES destination review" width="1226" height="1087" data-path="images/amazonses-destinationreview.png" />
</Frame>

Review the information for the destination and click "Add Destination"

We also need to associate this configuration set with one of our verified identities. Click "Verified Identities"
on the sidebar and click the identity you'll be using with Dittofeed.

Note: You can use multiple identities, just make sure to assign the configuration set to each.

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-defaultset.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=1371b7c6c9ee02dfcf8afd6453e80c0b" alt="AmazonSES default configuration set" width="1226" height="1087" data-path="images/amazonses-defaultset.png" />
</Frame>

Click the "Configuration Set" tab and "Edit" to set the default configuration set to the one we recently created.

Final step: Forward SNS messages to Dittofeed's webhook.

Visit the SNS service page in the AWS Console.

Click "Subscriptions" in the sidebar then "Create Subscription"

<Frame>
  <img src="https://mintcdn.com/dittofeed/MR-erTsdiKcJhyyj/images/amazonses-subscription.png?fit=max&auto=format&n=MR-erTsdiKcJhyyj&q=85&s=82a82d1fe323c19a4fb9a894098ba30e" alt="AmazonSES subscription" width="1209" height="1124" data-path="images/amazonses-subscription.png" />
</Frame>

Click the "Topic ARN" field and select the topic you created earlier.

Select HTTPS for "Protocol"

Enter `https://[mydittofeed]/api/public/webhooks/amazon-ses` replacing `[mydittofeed]` with the domain name of your dittofeed instance.

Click "Create subscription".

The subscription should be confirmed almost immediately. If not, check that the URL was entered correctly and your instance is reachable from AWS.
The API container's log output can also be useful to diagnose webhook issues.

Send a test email and check that new events populate in the events page.

Here's a video showing the full setup.

<iframe class="w-full aspect-video" src="https://www.youtube.com/embed/MGzv2sxxabA?si=mQ7bSNoC998uA5Vb" title="Integrating Amazon SES with Dittofeed to Automate Emails" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowFullScreen />
