---
name: aws-ses
description: |
  Amazon SES (Simple Email Service) sends and receives email through AWS: transactional and
  marketing mail, templates, bounce and complaint tracking, and inbound mail processing.
  Use when a user asks to send email with SES, verify a domain or set up DKIM, move an SES
  account out of the sandbox, create or bulk-send email templates, add an attachment or
  unsubscribe header, handle bounces and complaints with SNS, manage the suppression list,
  or store incoming mail in S3 with receipt rules. Covers the SES v2 API (aws sesv2, boto3
  sesv2).
license: Apache-2.0
compatibility: 'AWS CLI v2 (or v1 with the sesv2 commands), boto3; AWS credentials with SES permissions in the Region you send from'
metadata:
  author: terminal-skills
  version: "1.1.0"
  category: devops
  tags: "aws, ses, email, notifications"
---

# AWS SES

## Overview

Amazon Simple Email Service (SES) is a pay-per-message email platform for transactional, marketing, and notification mail. It also receives incoming email and hands it to S3, SNS, or Lambda. Use the v2 API (`aws sesv2`, `boto3.client('sesv2')`) for everything except receipt rules and `get-send-statistics`, which exist only in the v1 API (`aws ses`). Identities, templates, quotas and the sandbox status are all per Region.

- **Verified identity** — domain or email address authorized to send
- **Configuration set** — named group of settings and event destinations applied per message
- **Template** — stored subject and body with `{{variable}}` placeholders
- **Suppression list** — account-level list of addresses that hard-bounced or complained
- **Sandbox** — the state of every new account: verified recipients only, 200 messages per 24 hours, 1 per second

## Instructions

### Verify a domain

```bash
# Create the identity; Easy DKIM (2048-bit) is the default and doubles as domain verification
aws sesv2 create-email-identity --email-identity mail.brightcart.io

# Three tokens plus the hosted zone to build the CNAME records from
aws sesv2 get-email-identity --email-identity mail.brightcart.io \
  --query 'DkimAttributes.{Tokens:Tokens,Zone:SigningHostedZone,Status:Status}'
```

For each token publish `TOKEN._domainkey.mail.brightcart.io CNAME TOKEN.SIGNING_HOSTED_ZONE`. The hosted zone differs per Region, so read it from the response instead of hard-coding `dkim.amazonses.com`. Verification completes when SES sees all three records (DNS changes can take up to 72 hours).

```bash
# A single address instead of a domain: SES emails a confirmation link valid for 24 hours
aws sesv2 create-email-identity --email-identity orders@brightcart.io

# Custom MAIL FROM (aligns SPF for DMARC). Then publish on bounce.mail.brightcart.io:
#   MX  10 feedback-smtp.us-east-1.amazonses.com      TXT  "v=spf1 include:amazonses.com ~all"
aws sesv2 put-email-identity-mail-from-attributes --email-identity mail.brightcart.io \
  --mail-from-domain bounce.mail.brightcart.io --behavior-on-mx-failure USE_DEFAULT_VALUE

aws sesv2 list-email-identities --query 'EmailIdentities[].[IdentityName,VerificationStatus]'
```

### Sandbox, quota and statistics

```bash
aws sesv2 get-account --query '{Production:ProductionAccessEnabled,Quota:SendQuota,Sending:SendingEnabled}'
aws ses get-send-statistics --query 'SendDataPoints[-5:]'   # sends, bounces, complaints per 15-minute interval

aws sesv2 put-account-details --production-access-enabled --mail-type TRANSACTIONAL \
  --website-url https://brightcart.io --contact-language EN \
  --use-case-description "Order confirmations and password resets for registered customers" \
  --additional-contact-email-addresses ops@brightcart.io
```

AWS Support gives a first response within 24 hours. Until access is granted you can only send to verified identities and the mailbox simulator. Sandbox status is per Region.

### Send email

```bash
aws sesv2 send-email \
  --from-email-address "BrightCart <orders@mail.brightcart.io>" \
  --destination '{"ToAddresses":["dana.whitfield@oakridgeclinic.org"]}' \
  --content '{
    "Simple": {
      "Subject": {"Data": "Order confirmation #48213"},
      "Body": {
        "Html": {"Data": "<h1>Thank you!</h1><p>Your order has been confirmed.</p>"},
        "Text": {"Data": "Thank you! Your order has been confirmed."}
      }
    }
  }' \
  --configuration-set-name prod-tracking
```

`--configuration-set-name` must name an existing configuration set: create `prod-tracking` first (see Bounce and complaint handling) or omit the flag. `Content` takes exactly one of `Simple`, `Template` or `Raw` (a full MIME message). `Simple` and `Template` also accept `Headers` and `Attachments`, so attachments no longer require building raw MIME (see Example 1).

### Email templates

```bash
aws sesv2 create-email-template \
  --template-name order-confirmation \
  --template-content '{
    "Subject": "Order confirmation #{{orderNumber}}",
    "Html": "<h1>Hi {{customerName}},</h1><p>Your order #{{orderNumber}} for {{itemName}} is confirmed.</p><p>Total: ${{total}}</p>",
    "Text": "Hi {{customerName}},\nYour order #{{orderNumber}} for {{itemName}} is confirmed.\nTotal: ${{total}}"
  }'

# Render locally-supplied data against the stored template before sending
aws sesv2 test-render-email-template --template-name order-confirmation \
  --template-data '{"orderNumber":"48213","customerName":"Dana","itemName":"Trail Pack 30L","total":"89.00"}'

aws sesv2 send-email \
  --from-email-address "orders@mail.brightcart.io" \
  --destination '{"ToAddresses":["dana.whitfield@oakridgeclinic.org"]}' \
  --content '{"Template": {"TemplateName": "order-confirmation",
    "TemplateData": "{\"orderNumber\":\"48213\",\"customerName\":\"Dana\",\"itemName\":\"Trail Pack 30L\",\"total\":\"89.00\"}"}}'
```

```python
# Bulk send: one personalized message per entry, at most 50 entries per call. Assumes a
# `weekly-newsletter` template with {{name}} and {{picks}} and a `marketing-tracking` configuration set.
import json
import boto3

ses = boto3.client('sesv2', region_name='us-east-1')
subscribers = [
    {'email': 'alice.moreno@oakridgeclinic.org', 'name': 'Alice', 'picks': 'Trail Pack 30L, Merino Socks'},
    {'email': 'omar.haddad@fernwoodlabs.net', 'name': 'Omar', 'picks': 'Summit Tent 2P, Camp Stove'},
]

response = ses.send_bulk_email(
    FromEmailAddress='news@mail.brightcart.io',
    DefaultContent={'Template': {'TemplateName': 'weekly-newsletter',
                                 'TemplateData': json.dumps({'name': 'there', 'picks': ''})}},
    BulkEmailEntries=[
        {'Destination': {'ToAddresses': [s['email']]},
         'ReplacementEmailContent': {'ReplacementTemplate': {
             'ReplacementTemplateData': json.dumps({'name': s['name'], 'picks': s['picks']})}}}
        for s in subscribers
    ],
    ConfigurationSetName='marketing-tracking',
)
for sub, result in zip(subscribers, response['BulkEmailEntryResults']):
    print(sub['email'], result['Status'], result.get('MessageId') or result.get('Error'))
```

The call succeeds even when individual entries fail; check each `Status` (`SUCCESS`, `MESSAGE_REJECTED`, `ACCOUNT_THROTTLED`, ...). A message whose template data is missing a variable is accepted and then dropped, visible only as a `RENDERING_FAILURE` event.

### Bounce and complaint handling

```bash
aws sesv2 create-configuration-set --configuration-set-name prod-tracking

aws sesv2 create-configuration-set-event-destination \
  --configuration-set-name prod-tracking \
  --event-destination-name bounce-handler \
  --event-destination '{
    "Enabled": true,
    "MatchingEventTypes": ["BOUNCE", "COMPLAINT", "RENDERING_FAILURE"],
    "SnsDestination": {"TopicArn": "arn:aws:sns:us-east-1:111122223333:ses-events"}
  }'
```

```python
# Lambda subscribed to the SNS topic
import json

def handler(event, context):
    for record in event['Records']:
        message = json.loads(record['Sns']['Message'])
        # Event publishing uses "eventType"; identity feedback notifications use "notificationType"
        kind = message.get('eventType') or message.get('notificationType')

        if kind == 'Bounce' and message['bounce']['bounceType'] == 'Permanent':
            for recipient in message['bounce']['bouncedRecipients']:
                mark_undeliverable(recipient['emailAddress'])      # your own data store
        elif kind == 'Complaint':
            for recipient in message['complaint']['complainedRecipients']:
                unsubscribe(recipient['emailAddress'])
```

SES also keeps an account-level suppression list and silently skips addresses on it:

```bash
aws sesv2 put-account-suppression-attributes --suppressed-reasons BOUNCE COMPLAINT
aws sesv2 list-suppressed-destinations --reasons BOUNCE
aws sesv2 get-suppressed-destination --email-address dana.whitfield@oakridgeclinic.org
aws sesv2 put-suppressed-destination --email-address old.account@fernwoodlabs.net --reason BOUNCE
```

### Receiving email

Verify the receiving domain itself as an identity (`aws sesv2 create-email-identity --email-identity brightcart.io`; the `mail.` subdomain does not cover it), publish an MX record for it (`10 inbound-smtp.us-east-1.amazonaws.com`; only some Regions have an inbound endpoint), then create receipt rules with the v1 API:

```bash
aws ses create-receipt-rule-set --rule-set-name inbound-rules
aws ses set-active-receipt-rule-set --rule-set-name inbound-rules

aws ses create-receipt-rule \
  --rule-set-name inbound-rules \
  --rule '{
    "Name": "process-support-emails",
    "Enabled": true,
    "Recipients": ["support@brightcart.io"],
    "Actions": [
      {"S3Action": {"BucketName": "brightcart-inbound-mail", "ObjectKeyPrefix": "support/"}},
      {"LambdaAction": {"FunctionArn": "arn:aws:lambda:us-east-1:111122223333:function:process-support-email"}}
    ]
  }'
```

The bucket policy must allow `ses.amazonaws.com` to `s3:PutObject`, and the function needs a resource policy that lets SES invoke it; otherwise `create-receipt-rule` fails.

## Examples

### Example 1: Order confirmation with a PDF invoice

**User request:** "Send the order confirmation from our Python backend with the invoice PDF attached, and make sure a throttled send is retried."

```python
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError

ses = boto3.client('sesv2', region_name='us-east-1',
                   config=Config(retries={'mode': 'adaptive', 'max_attempts': 5}))

with open('invoices/INV-48213.pdf', 'rb') as f:
    invoice = f.read()

try:
    response = ses.send_email(
        FromEmailAddress='BrightCart <orders@mail.brightcart.io>',
        Destination={'ToAddresses': ['dana.whitfield@oakridgeclinic.org']},
        ReplyToAddresses=['support@brightcart.io'],
        Content={'Simple': {
            'Subject': {'Data': 'Your BrightCart order #48213'},
            'Body': {'Html': {'Data': '<p>Thanks, Dana. Your invoice is attached.</p>'},
                     'Text': {'Data': 'Thanks, Dana. Your invoice is attached.'}},
            'Attachments': [{'FileName': 'INV-48213.pdf', 'RawContent': invoice,
                             'ContentType': 'application/pdf'}],
        }},
        ConfigurationSetName='prod-tracking',
        EmailTags=[{'Name': 'type', 'Value': 'order-confirmation'}],
    )
    print(response['MessageId'])
except ClientError as err:
    # MessageRejected, MailFromDomainNotVerifiedException, AccountSuspendedException, ...
    print(err.response['Error']['Code'], err.response['Error']['Message'])
    raise
```

Result: the script prints the SES message ID, for example `0100019a2c4e7f31-5d0c8b7e-3f41-4a55-9d2e-7c1b6a40e9d2-000000`. `TooManyRequestsException` is retried by the SDK; in the sandbox an unverified recipient raises `MessageRejected` with "Email address is not verified".

### Example 2: Test bounce handling without hurting reputation

**User request:** "Before we go live, prove that a hard bounce reaches our SNS topic."

```bash
aws sesv2 send-email \
  --from-email-address orders@mail.brightcart.io \
  --destination '{"ToAddresses":["bounce@simulator.amazonses.com"]}' \
  --content '{"Simple":{"Subject":{"Data":"Bounce test"},"Body":{"Text":{"Data":"Simulated hard bounce"}}}}' \
  --configuration-set-name prod-tracking
```

Within seconds the SNS topic receives a record like this (trimmed):

```json
{
  "eventType": "Bounce",
  "bounce": {
    "bounceType": "Permanent",
    "bounceSubType": "General",
    "bouncedRecipients": [
      {"emailAddress": "bounce@simulator.amazonses.com", "action": "failed", "status": "5.1.1",
       "diagnosticCode": "smtp; 550 5.1.1 user unknown"}
    ]
  },
  "mail": {"source": "orders@mail.brightcart.io", "tags": {"ses:configuration-set": ["prod-tracking"]}}
}
```

Other simulator addresses: `success@`, `complaint@`, `ooto@` and `suppressionlist@simulator.amazonses.com`. Simulator mail works in the sandbox and does not count toward the daily quota or the bounce and complaint rates, but it is billed.

## Guidelines

- Send from a subdomain (`mail.brightcart.io`) with DKIM, a custom MAIL FROM and a DMARC record, so marketing problems do not damage the main domain.
- Set up bounce and complaint handling before sending at volume. AWS puts an account under review at a 5% bounce rate or a 0.1% complaint rate and may pause sending at 10% or 0.5%.
- Remove permanently bounced addresses from your own lists as well; the suppression list only stops SES from retrying them.
- Bulk and marketing mail must carry one-click unsubscribe (`List-Unsubscribe` and `List-Unsubscribe-Post` headers), required by Gmail and Yahoo. Either pass them in `Headers`, or use an SES contact list with `ListManagementOptions` and the `{{amazonSESUnsubscribeUrl}}` placeholder.
- `TemplateData` is a JSON **string**, not an object; build it with `json.dumps` rather than by hand.
- Grant the sending role only `ses:SendEmail` (and `ses:SendBulkEmail` if needed), restricted to the ARNs of the identity, configuration set and templates it uses; do not hand application servers `ses:*`.
- Never put AWS keys in code. Use an instance or task role, or a named profile through `AWS_PROFILE`.
- Open tracking is unreliable (mail clients prefetch images; events carry `isBotEvent`). Use delivery, bounce and complaint events for decisions.
- Not a mailbox: SES receiving hands messages to S3, SNS or Lambda and offers no IMAP or POP3. For hosted mailboxes use a mail provider.


---
Source attribution: TerminalSkills
Original project: https://github.com/TerminalSkills/skills/blob/3bfbf7f76459d89422eddc0e5f572ad0e6c393c9/skills/aws-ses/SKILL.md
License: Apache-2.0
License information: https://www.apache.org/licenses/LICENSE-2.0
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to the Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by the Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding any notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   Copyright 2025 Terminal Skills

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



# Mega AI Hub resource metadata

Creator / publisher: TerminalSkills
Original project: https://github.com/TerminalSkills/skills/blob/3bfbf7f76459d89422eddc0e5f572ad0e6c393c9/skills/aws-ses/SKILL.md
Attribution basis: Source repository record

Fields of work: Marketing
Roles: Email Marketer, Growth Marketer, Marketing Analyst
Specialties: API
Tools: AWS, Email (SMTP/IMAP)
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 9f773e82a4a3e69f2a7ab61a8ef238ea5f8d909e9391b18b3a7fa29276a14f47
