# Amazon SES Send and receive a domain's mail through Amazon SES (Simple Email Service). ## Prerequisites - A domain on Cloudflare DNS and a [`CF_TOKEN`](deploy-cloudflare.md#1-create-cf_token). - For receiving: `APP_URL` set to a public HTTPS address. ## Set up 1. Create an IAM user with programmatic access and attach the policy below. 2. Enter its **access key ID**, **secret access key** and **region** in the SES card. 3. Follow the [setup steps](providers.md#set-up-a-provider). Mailflare tests the key before saving and lists missing permissions. For sending only, you need just the sending permissions. ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["sts:GetCallerIdentity", "ses:GetAccount", "ses:SendEmail", "ses:CreateEmailIdentity", "ses:GetEmailIdentity", "ses:DeleteEmailIdentity", "ses:SetIdentityNotificationTopic"], "Resource": "*" }, { "Effect": "Allow", "Action": ["ses:DescribeActiveReceiptRuleSet", "ses:CreateReceiptRuleSet", "ses:SetActiveReceiptRuleSet", "ses:CreateReceiptRule", "ses:UpdateReceiptRule", "ses:DescribeReceiptRule", "ses:DeleteReceiptRule"], "Resource": "*" }, { "Effect": "Allow", "Action": ["sns:ListTopics", "sns:CreateTopic", "sns:SetTopicAttributes", "sns:Subscribe", "sns:ListSubscriptionsByTopic"], "Resource": "*" }, { "Effect": "Allow", "Action": ["s3:ListAllMyBuckets", "s3:CreateBucket", "s3:PutBucketPolicy", "s3:PutLifecycleConfiguration", "s3:ListBucket", "s3:GetObject", "s3:DeleteObject"], "Resource": "*" } ] } ``` **Sending setup** creates the SES identity, publishes three DKIM CNAME records and tracks verification. Replies thread on the Message-ID that SES assigns (`` in `us-east-1`, `` elsewhere). New AWS accounts are in the **SES sandbox** and deliver only to verified addresses; request production access in the SES console. **Receiving setup** works only in some regions (for example `us-east-1`, `us-west-2`, `eu-west-1`). It creates, and is safe to run again: 1. An S3 bucket `mailflare-inbound--` that only SES can write to; leftovers expire after one day (best effort). 2. An SNS topic that only SES can publish to, subscribed to `/api/inbound/ses` with a secret token. 3. A receipt rule in your active rule set. `mailflare-inbound` is created and activated only if you have none. 4. The MX record `inbound-smtp..amazonaws.com`. Each message is read from your bucket, processed and deleted. Infected messages are dropped. ## Configuration | Variable | Purpose | | --- | --- | | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION` | SES credentials | | `APP_URL` | Public HTTPS address for receiving | **Environment variables take precedence over keys saved in the app.** Saved keys are stored as plain text in the database, so protect your backups. ## Clean up | Part | Clean up removes | | --- | --- | | Sending | The identity and DKIM records | | Receiving | The domain's receipt rule and MX; the shared bucket and topic stay | ## Troubleshooting | Problem | Cause | Fix | | --- | --- | --- | | Domain "not verified" | DNS not seen or wrong | [Check records](troubleshooting.md#resend-or-ses-domain-stays-not-verified) | | Sends fail to most addresses | Sandbox | Request production access | | Receiving setup fails | Region, `APP_URL` or permissions | [SES checklist](troubleshooting.md#ses-receiving-setup-fails) | ## Related - [All providers](providers.md)