

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 设置 Amazon SES 事件发布
<a name="monitor-sending-using-event-publishing-setup"></a>

本节介绍配置 Amazon SES 以将您的电子邮件发送事件发布到以下 AWS 服务所需的操作：
+ Amazon CloudWatch
+ Amazon Data Firehose
+ Amazon Pinpoint
+ Amazon Simple Notiﬁcation Service（Amazon SNS）

以下主题介绍了设置事件发布所需的以下步骤：

1. 必须使用 Amazon SES 控制台或 API 创建一个*配置集*。

1. 将一个或多个*事件目标*（Firehose CloudWatch、Pinpoint 或 SNS）添加到配置集，并配置事件目标的唯一参数。

1. 在发送电子邮件时，指定要使用的包含事件目标的配置集。

**Topics**
+ [步骤 1：创建配置集](event-publishing-create-configuration-set.md)
+ [步骤 2：添加事件目标](event-publishing-add-event-destination.md)
+ [步骤 3：在发送电子邮件时指定配置集](event-publishing-send-email.md)

# 步骤 1：创建配置集
<a name="event-publishing-create-configuration-set"></a>

必须首先具有配置集以设置事件发布。如果您还没有配置集，或者希望创建新配置集，请参阅 [在 SES 中创建配置集](creating-configuration-sets.md)

您也可以使用 Amazon SES API V2 或 Amazon SES CLI v2 中的[CreateConfigurationSet](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_CreateConfigurationSet.html)操作创建配置集，请参阅。[创建一个配置集 (AWS CLI)](creating-configuration-sets.md#config-sets-create-cli)

# 步骤 2：添加事件目标
<a name="event-publishing-add-event-destination"></a>

事件目标是将 Amazon SES 事件发布到的位置。您设置的每个事件目标都属于一个（且仅属于一个）配置集。使用 Amazon SES 设置活动目的地时，您可以选择 AWS 服务目的地，然后指定与该目的地关联的参数。

设置活动目的地时，可以选择将事件发送到以下 AWS 服务之一：
+ Amazon CloudWatch
+ Amazon Data Firehose
+ Amazon EventBridge
+ Amazon Pinpoint
+ Amazon Simple Notiﬁcation Service（Amazon SNS）

您选择的事件目标取决于您所需的事件详细级别，以及您所需的接收事件信息的方式。如果您只想了解每一类事件的运行总数（例如，为了可以设置在总数过高时发出警报），可以使用 CloudWatch。

如果您想将详细的事件记录输出到其他服务（例如亚马逊 OpenSearch 服务或亚马逊 Redshift）进行分析，则可以使用 Firehose。

如果您想要在某些事件发生时接收通知，可以使用 Amazon SNS。

**Topics**
+ [为 CloudWatch 活动发布设置活动目的地](event-publishing-add-event-destination-cloudwatch.md)
+ [为 Amazon SES 事件发布设置 Data Firehose 事件目标](event-publishing-add-event-destination-firehose.md)
+ [为活动发布设置一个 Amazon EventBridge 目的地](event-publishing-add-event-destination-eventbridge.md)
+ [针对事件发布设置 Amazon Pinpoint 事件目标](event-publishing-add-event-destination-pinpoint.md)
+ [针对事件发布设置 Amazon SNS 事件目标](event-publishing-add-event-destination-sns.md)

# 为 CloudWatch 活动发布设置活动目的地
<a name="event-publishing-add-event-destination-cloudwatch"></a>

借助[亚马逊 CloudWatch 指标](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/working_with_metrics.html)，您可以使用事件目标发布向发送事件的 Amazon SES 电子邮件 CloudWatch。由于只能在配置集中设置 CloudWatch 事件目的地，因此必须先[创建配置集](event-publishing-create-configuration-set.md)，然后将事件目标添加到配置集中。

将 CloudWatch 事件目标添加到配置集时，必须选择一个或多个与发送电子邮件时使用的消息标签相对应的 CloudWatch *维度*。与消息标签一样， CloudWatch 维度是帮助您唯一标识指标的 name/value 配对。

例如，您可以有名为 `campaign` 的一个邮件标签和一个维度，用于标识您的电子邮件营销活动。当您将电子邮件发送事件发布到时 CloudWatch，选择消息标签和维度非常重要，因为这些选择会影响您的 CloudWatch 账单，并决定如何筛选电子邮件发送事件数据 CloudWatch。

本节提供的信息可帮助您选择维度，然后说明如何向配置集添加 CloudWatch 事件目的地。

**Topics**
+ [添加 CloudWatch 活动目的地](#event-publishing-add-event-destination-cloudwatch-add)
+ [选择 CloudWatch 尺寸](#event-publishing-add-event-destination-cloudwatch-dimensions)

## 添加 CloudWatch 活动目的地
<a name="event-publishing-add-event-destination-cloudwatch-add"></a>

本节中的过程说明如何将 CloudWatch 事件目标详细信息添加到配置集中，并假设您已经完成了中的步骤 1 到步骤 6 [创建事件目标](event-destinations-manage.md#event-destination-add)。

您还可以使用 Amazon SES API V2 中的[UpdateConfigurationSetEventDestination](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_UpdateConfigurationSetEventDestination.html)操作来创建和修改事件目的地。

**使用控制台向配置集添加 CloudWatch 事件目标详细信息**

1. 以下是在[步骤 7](event-destinations-manage.md#specify-event-dest-step) 中选择 CloudWatch 活动目的地类型的详细说明，并假设您已完成中之前的所有步骤[创建事件目标](event-destinations-manage.md#event-destination-add)。选择 CloudWatch **目标类型、输入目标****名称**并启用**事件发布**后，将显示 **Amazon CloudWatch 维度**窗格，其字段将在以下步骤中进行处理。*（需支付额外费用，请参阅[每个指标的价格 CloudWatch](#cw-add-pricing)。）* 

1. 对于**值来源**，指定 Amazon SES 将如何获取其传递到的数据 CloudWatch。提供了以下值来源：
   + **邮件标签**：Amazon SES 从使用 `X-SES-MESSAGE-TAGS` 标头或 `EmailTags` API 参数指定的标签中检索维度名称和值。有关使用邮件标签的更多信息，请参阅 [步骤 3：在发送电子邮件时指定配置集](event-publishing-send-email.md)。
**注意**  
邮件标签可以包含数字 0-9、字母 A-Z（大写和小写字母）、连字符（-）和下划线（\$1）。

     您也可以使用 **Message Tag (邮件标签)** 值来源根据 Amazon SES 自动标签创建维度。要使用自动标签，请键入自动标签的完整名称以作为 **Dimension Name (维度名称)**。例如，要根据配置集自动标签创建维度，请将 `ses:configuration-set` 作为 **Dimension Name (维度名称)** 并将配置集的名称作为 **Default Value (默认值)**。有关完整的自动标签列表，请参阅 [事件发布如何与配置集和消息标签协同工作](monitor-using-event-publishing.md#event-publishing-how-works)。
   + **Email Header (电子邮件标头)**：Amazon SES 从电子邮件中的标头检索维度名称和值。
**注意**  
您不能使用以下任意电子邮件标头作为 **Dimension Name (维度名称)**：`Received`、`To`、`From`、`DKIM-Signature`、`CC`、`message-id` 或 `Return-Path`。
   + **Link Tag (链接标签)**：Amazon SES 从您在链接中指定的标签检索维度名称和值。有关向链接添加标签的更多信息，请参阅 [我能否用唯一标识符来标记链接？](faqs-metrics.md#sending-metric-faqs-clicks-q5)。

1. 对于 **Dimension Name (维度名称)**，请键入要传递到 CloudWatch 的维度的名称。
**注意**  
维度名称只能包含 ASCII 字母 (a-z , A-Z )、数字 (0 - 9 )、下划线 (\$1) 和dashes (-)。不允许使用空格、重音字符、非拉丁字符和其他特殊字符。

1. 对于 **Default Value**（默认值），请键入维度的值。
**注意**  
维度值只能包含 ASCII 字母（a-z、A-Z）、数字 (0-9)、下划线 (\$1)、短划线 (-)、@ 符号和句点 (.)。不允许使用空格、重音字符、非拉丁字符和其他特殊字符。

1. 如果要添加更多维度，请选择 **Add Dimension**（添加维度）。否则，请选择 **Next**（下一步）。

1. 在审核屏幕上，如果您对定义事件目标的方式感到满意，请选择**添加目标**。

## 选择 CloudWatch 尺寸
<a name="event-publishing-add-event-destination-cloudwatch-dimensions"></a>

选择用作 CloudWatch 维度的名称和值时，请考虑以下因素：
+ **每个指标的价格** — 您可以免费查看基本的 Amazon SES 指标。 CloudWatch 但是，当您使用事件发布收集指标时，会产生[CloudWatch 详细监控](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-metrics-basic-detailed.html)费用。事件类型、维度名称和维度值的每个唯一组合都会在中创建不同的指标 CloudWatch。当您使用 CloudWatch “详细监控” 时，您需要为每个指标付费。出于此原因，您可能想要避免选择需要许多不同值的维度。例如，除非对通过“发件人”域跟踪电子邮件发送事件非常感兴趣，否则可能不希望为 Amazon SES 自动标签 `ses:from-domain` 定义维度，因为它可能需要许多不同的值。有关更多信息，请参阅[CloudWatch 定价](https://aws.amazon.com/cloudwatch/pricing)。
+ **指标筛选**-如果一个指标有多个维度，则无法 CloudWatch 根据每个维度分别访问该指标。出于这个原因，在为单个 CloudWatch 活动目的地添加多个维度之前，请仔细考虑。例如，如果要按 `campaign` 或 `campaign` 和 `genre` 组合查看指标，您需要添加两个事件目标：一个目标仅将 `campaign` 作为维度，另一个目标将 `campaign` 和 `genre` 作为维度。
+ **维度值来源**：除了使用特定于 Amazon SES 的标头或 API 的参数指定维度值之外，您还可以选择让 Amazon SES 从您自己的 MIME 消息标头中获取维度值。如果您已在使用自定义标头并且不想更改电子邮件或对电子邮件发送 API 的调用以根据标头值收集指标，则可以使用此选项。如果对 Amazon SES 事件发布使用自己的 MIME 邮件标头，则用于 Amazon SES 事件发布的标头名称和值只能包含字母 A-Z、数字 0-9、下划线 (\$1)、at 符号 (@)、连字符 (-) 和句点 (.)。如果您指定的名称或值包含其他字符，则发送电子邮件的呼叫仍将成功，但不会将事件指标发送到 Amazon CloudWatch。

有关 CloudWatch 概念的更多信息，请参阅[亚马逊* CloudWatch 用户指南中的亚马逊 CloudWatch *概念](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html)。

# 为 Amazon SES 事件发布设置 Data Firehose 事件目标
<a name="event-publishing-add-event-destination-firehose"></a>

Amazon Data Firehose 事件目标代表将特定的 Amazon SES 电子邮件发送事件发布到 Firehose 的实体。由于 Firehose 事件目标只能在配置集中设置，因此首先必须[创建配置集](event-publishing-create-configuration-set.md)。接下来，将事件目标添加到配置集中。

本节中的过程演示如何将 Firehose 事件目标详细信息添加到配置集，并假设您已完成 [创建事件目标](event-destinations-manage.md#event-destination-add) 中的步骤 1 到 6。

您还可以使用 Amazon SES API V2 目标中的[UpdateConfigurationSetEventDestination](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_UpdateConfigurationSetEventDestination.html)操作来创建和更新事件目标。

**使用控制台将 Firehose 事件目标详细信息添加到配置集**

1. 以下是[步骤 7](event-destinations-manage.md#specify-event-dest-step) 中选择 Firehose 作为事件目标类型的详细说明，并假设您已完成[创建事件目标](event-destinations-manage.md#event-destination-add)中的所有之前的步骤。在选择 Firehose **目标类型**，输入目标**名称**并启用**事件发布**后，**Amazon Data Firehose 传输留**窗格将显示，其字段将在以下步骤中得到处理。

1. 对于**传输流**，请选择现有的 Firehose 传输流，或选择**创建新流**以使用 Firehose 控制台创建新的传输流。

   有关使用 Firehose 控制台创建流的信息，请参阅《Amazon Data Firehose 开发人员指南》**中的[创建 Amazon Kinesis Firehose 传输流](https://docs.aws.amazon.com/firehose/latest/dev/basic-create.html)。

1. 对于 **Identity and Access Management（IAM）角色**，请选择一个 Amazon SES 有权限代表您发布到 Firehose 的 IAM 角色。您可以选择现有角色，或者让 Amazon SES 为您创建一个角色，也可以创建自己的角色。

   如果您选择现有角色或创建自己的角色，您必须手动修改该角色的策略，授予该角色访问 Firehose 传输流的权限，并授予 Amazon SES 代入该角色的权限。有关示例策略，请参阅 [授予 Amazon SES 发布到 Firehose 传输流的权限](#event-publishing-add-event-destination-firehose-role)。

1. 选择**下一步**。

1. 在审核屏幕上，如果您对定义事件目标的方式感到满意，请选择**添加目标**。

有关如何使用 `UpdateConfigurationSetEventDestination` API 添加 Firehose 事件目标的信息，请参阅 [Amazon Simple Email Service API 参考](https://docs.aws.amazon.com/ses/latest/APIReference/API_UpdateConfigurationSetEventDestination.html)。

## 授予 Amazon SES 发布到 Firehose 传输流的权限
<a name="event-publishing-add-event-destination-firehose-role"></a>

要允许 Amazon SES 向您的 Firehose 传输流发布记录，您必须使用 AWS Identity and Access Management （IAM）[角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)，并附加或修改该角色的权限策略和信任策略。权限策略允许该角色向您的 Firehose 传输流发布记录，信任策略允许 Amazon SES 代入该角色。

本部分提供有关两个策略的一些示例。有关向 IAM 角色添加策略的信息，请参阅《IAM 用户指南》**中的[修改角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_modify.html)。

### 权限策略
<a name="event-publishing-add-event-destination-firehose-role-permission"></a>

以下权限策略允许角色发布数据记录到您的 Firehose 传输流。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": [
                "firehose:PutRecordBatch"
            ],
            "Resource": [
                "arn:aws:firehose:us-east-1:111122223333:deliverystream/delivery-stream-name"
            ]
        }
    ]
}
```

------

对前面的策略示例进行以下更改：
+ *delivery-region*替换为您创建 Firehose 传送流的 AWS 区域。
+ 将 *111122223333* 替换为您的 AWS 账户 ID。
+ *delivery-stream-name*替换为 Firehose 传送流的名称。

### 信任策略
<a name="event-publishing-add-event-destination-firehose-role-trust"></a>

以下信任策略使 Amazon SES 能够代入该角色。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "ses.amazonaws.com"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "AWS:SourceAccount": "111122223333",
          "AWS:SourceArn": "arn:aws:ses:delivery-region:111122223333:configuration-set/configuration-set-name"
        }
      }
    }
  ]
}
```

------

对前面的策略示例进行以下更改：
+ *delivery-region*替换为您创建 Firehose 传送流的 AWS 区域。
+ 将 *111122223333* 替换为您的 AWS 账户 ID。
+ 替换为*configuration-set-name*与 Firehose 交付流关联的配置集的名称。

# 为活动发布设置一个 Amazon EventBridge 目的地
<a name="event-publishing-add-event-destination-eventbridge"></a>

Amazon EventBridge 事件目标会通知您有关您在配置集中指定的电子邮件发送事件。SES 生成电子邮件发送事件，并将您在创建事件目的地时定义的事件发送到 EventBridge 默认事件总线。[事件总线](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus.html)是接收事件并将其传送到多个目的地的路由器。您可以在中详细了解如何将电子邮件发送事件与 Amazon EventBridge 集成[使用 Amazon 监控 SES 事件 EventBridge](monitoring-eventbridge.md)。由于只能在配置集中设置 EventBridge事件目的地，因此必须先[创建配置集](event-publishing-create-configuration-set.md)，然后才能将事件目标添加到配置集中。

本节中的过程说明如何将 EventBridge 事件目标详细信息添加到配置集中，并假设您已经完成了中的步骤 1 到步骤 6 [创建事件目标](event-destinations-manage.md#event-destination-add)。

您还可以使用 Amazon SES API V2 中的[UpdateConfigurationSetEventDestination](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_UpdateConfigurationSetEventDestination.html)操作来创建和修改事件目的地。

**使用控制台将 EventBridge 事件目标详细信息添加到配置集中**

1. 以下是在[步骤 7](event-destinations-manage.md#specify-event-dest-step) 中选择 EventBridge 活动目的地类型的详细说明，并假设您已完成中之前的所有步骤[创建事件目标](event-destinations-manage.md#event-destination-add)。选择*亚马逊 EventBridge***目标类型**、输入目标**名称**并启用**活动发布**后，将显示**亚马逊 EventBridge 事件总线**信息窗格。

1. 选择**下一步**。

1. 在审核屏幕上，如果您对定义事件目标的方式感到满意，请选择**添加目标**。这将打开活动目的地的摘要页面，成功横幅将确认您的活动目的地是否已成功创建或修改。

# 针对事件发布设置 Amazon Pinpoint 事件目标
<a name="event-publishing-add-event-destination-pinpoint"></a>

Amazon Pinpoint 事件目标会通知您有关您在配置集中指定的电子邮件发送事件。由于 Amazon Pinpoint 事件目标只能在配置集中设置，您必须先[创建配置集](event-publishing-create-configuration-set.md)，再将事件目标添加到该配置集。

本节中的过程演示如何将 Amazon Pinpoint 事件目标详细信息添加到配置集，并假设您已完成 [创建事件目标](event-destinations-manage.md#event-destination-add) 中的步骤 1 到 6。

您还可以使用 Amazon SES API V2 中的[UpdateConfigurationSetEventDestination](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_UpdateConfigurationSetEventDestination.html)操作来创建和修改事件目标。

您在 Amazon Pinpoint 项目中配置的通道类型需要额外支付费用。有关更多信息，请参阅 [Amazon Pinpoint 定价](https://aws.amazon.com/pinpoint/pricing/)。

**使用控制台将 Amazon Pinpoint 事件目标详细信息添加到配置集**

1. 以下是[步骤 7](event-destinations-manage.md#specify-event-dest-step) 中选择 Amazon Pinpoint 作为事件目标类型的详细说明，并假设您已完成[创建事件目标](event-destinations-manage.md#event-destination-add)中所有之前的步骤。
**注意**  
Amazon Pinpoint 不支持 **Delivery delays**（送达延迟）或 **Subscriptions**（订阅）事件类型。

   在选择 Amazon Pinpoint **目标类型**，输入目标**名称**并启用**事件发布**后，**Amazon Pinpoint 项目详细信息**窗格将显示，其字段将在以下步骤中得到处理。

1. 对于 **Project**（项目），选择现有的 Amazon Pinpoint 项目，或者选择 **Create a new project in Amazon Pinpoint**（在 Amazon Pinpoint 中创建新项目）以创建新项目。

   有关创建项目的信息，请参阅*《Amazon Pinpoint 用户指南》*中的[创建项目](https://docs.aws.amazon.com/pinpoint/latest/userguide/gettingstarted-create-project.html)。

1. 选择**下一步**。

1. 在审核屏幕上，如果您对定义事件目标的方式感到满意，请选择**添加目标**。这将打开活动目的地的摘要页面，成功横幅将确认您的活动目的地是否已成功创建或修改。

# 针对事件发布设置 Amazon SNS 事件目标
<a name="event-publishing-add-event-destination-sns"></a>

Amazon SNS 事件目标会通知您有关您在配置集中指定的电子邮件发送事件。由于 Amazon SNS 事件目标只能在配置集中设置，您必须先[创建配置集](event-publishing-create-configuration-set.md)，再将事件目标添加到该配置集。

本节中的过程演示如何将 Amazon SNS 事件目标详细信息添加到配置集，并假设您已完成 [创建事件目标](event-destinations-manage.md#event-destination-add) 中的步骤 1 到 6。

您还可以使用 Amazon SES API V2 中的[UpdateConfigurationSetEventDestination](https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_UpdateConfigurationSetEventDestination.html)操作来创建和修改事件目的地。

**注意**  
也可以通过 Amazon SNS 为任何经过验证的发送身份设置有关退信、投诉和送达的反馈通知。有关更多信息，请参阅[为 Amazon SES 配置 Amazon SNS 通知](configure-sns-notifications.md)。

向订阅 Amazon SNS 主题的端点发送消息会产生额外费用。有关更多信息，请参阅 [Amazon SNS 定价](https://aws.amazon.com/sns/pricing/)。

**使用控制台将 Amazon SNS 事件目标详细信息添加到配置集**

1. 以下是[步骤 7](event-destinations-manage.md#specify-event-dest-step) 中选择 Amazon SNS 作为事件目标类型的详细说明，并假设您已完成[创建事件目标](event-destinations-manage.md#event-destination-add)中的所有之前的步骤。在选择 Amazon SNS **目标类型**，输入目标**名称**并启用**事件发布**后，**Amazon Simple Notification Service（SNS）主体**窗格将显示，其字段将在以下步骤中得到处理。

1. 对于 **SNS topic**（SNS 主题），选择现有的 Amazon SNS 主题，或选择 **Create SNS topic**（创建 SNS 主题）以创建一个新主题。

   有关创建主题的信息，请参阅*《Amazon Simple Notification Service 开发人员指南》*中的[创建主题](https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html)。
**重要**  
当您使用 Amazon SNS 创建主题时，对于 **Type (类型)**，仅选择 **Standard (标准)**。（SES 不支持 FIFO 类型主题。）

1. 选择**下一步**。

1. 在审核屏幕上，如果您对定义事件目标的方式感到满意，请选择**添加目标**。这将打开活动目的地的摘要页面，成功横幅将确认您的活动目的地是否已成功创建或修改。

1. 无论是创建新的 SNS 主题还是选择现有主题，都需要授予 SES 访问权限，才能向该主题发布通知。在上一步的事件目标的摘要页面中，从 **Destination type**（目标类型）列中选择 **Amazon SNS** - 这将转到 Amazon Simple Notification Service 控制台中的 **Topics**（主题）列表 - *从 Amazon SNS 控制台执行以下步骤：*

   1. 选择您在上一步中创建或修改的 SNS 主题的名称。

   1. 在主题的详细信息屏幕上，选择**编辑**。

   1. 要授予 SES 发布主题通知的权限，请在 SNS 控制台的**编辑主题**屏幕上，展开**访问策略**，并在 **JSON 编辑器**中，添加以下权限策略：

------
#### [ JSON ]

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Id": "notification-policy",
          "Statement": [
              {
                  "Effect": "Allow",
                  "Principal": {
                      "Service": "ses.amazonaws.com"
                  },
                  "Action": "sns:Publish",
                  "Resource": "arn:aws:sns:us-east-1:111122223333:topic_name",
                  "Condition": {
                      "StringEquals": {
                          "AWS:SourceAccount": "111122223333",
                          "AWS:SourceArn": "arn:aws:ses:topic_region:111122223333:configuration-set/configuration-set-name"
                      }
                  }
              }
          ]
      }
      ```

------

      对前面的策略示例进行以下更改：
      + *topic\$1region*替换为您创建 SNS 主题的 AWS 区域。
      + *111122223333*替换为您的 AWS 账户 ID。
      + *topic\$1name*替换为您的 SNS 主题的名称。
      + 替换为*configuration-set-name*与 SNS 事件目标关联的配置集的名称。

   1. 选择**保存更改**。

# 步骤 3：在发送电子邮件时指定配置集
<a name="event-publishing-send-email"></a>

在[创建配置集](event-publishing-create-configuration-set.md)和[添加事件目标](event-publishing-add-event-destination.md)后，事件发布的最后一步是发送您的电子邮件。

要发布与电子邮件相关联的事件，您必须提供配置集名称以便与电子邮件相关联。您还可以选择性地提供邮件标签以对电子邮件进行分类。

您可以以电子邮件发送 API 的参数、特定于 Amazon SES 的电子邮件标头或 MIME 邮件中的自定义标头的形式向 Amazon SES 提供这些信息。您选择的方法取决于所使用的电子邮件发送接口，如下表所示。


****  

| 电子邮件发送接口 | 发布事件的方式 | 
| --- | --- | 
|  `SendEmail`  |  API 参数  | 
|  `SendTemplatedEmail`  |  API 参数  | 
|  `SendBulkTemplatedEmail`  |  API 参数  | 
|  `SendCustomVerificationEmail`  |  API 参数  | 
|  `SendRawEmail`  |  API 参数、特定于 Amazon SES 的电子邮件标头或自定义 MIME 标头   如果同时使用标头和 API 参数指定邮件标签，Amazon SES 仅使用通过 API 参数提供的邮件标签。Amazon SES 不会合并由 API 参数和标头指定的邮件标签。   | 
|  SMTP 接口  |  特定于 Amazon SES 的电子邮件标头  | 

以下部分介绍如何使用标头和使用 API 参数指定配置集和邮件标签。
+ [使用 Amazon SES API 参数](#event-publishing-using-ses-parameters)
+ [使用特定于 Amazon SES 的电子邮件标头](#event-publishing-using-ses-headers)
+ [使用自定义电子邮件标头](#event-publishing-using-custom-headers)

**注意**  
还可以选择性地在电子邮件标头中包含邮件标签。邮件标签可以包含数字 0-9、字母 A-Z（大写和小写字母）、连字符（-）和下划线（\$1）。

## 使用 Amazon SES API 参数
<a name="event-publishing-using-ses-parameters"></a>

要将[SendEmail](https://docs.aws.amazon.com/ses/latest/APIReference/API_SendEmail.html)、[SendTemplatedEmail](https://docs.aws.amazon.com/ses/latest/APIReference/API_SendTemplatedEmail.html)、[SendBulkTemplatedEmail[SendCustomVerificationEmail](https://docs.aws.amazon.com/ses/latest/APIReference/API_SendCustomVerificationEmail.html)](https://docs.aws.amazon.com/ses/latest/APIReference/API_SendBulkTemplatedEmail.html)、或[SendRawEmail](https://docs.aws.amazon.com/ses/latest/APIReference/API_SendRawEmail.html)与事件发布一起使用，您可以通过将调用的数据结构传递给 API 调用[MessageTag](https://docs.aws.amazon.com/ses/latest/APIReference/API_MessageTag.html)来指定配置集[ConfigurationSet](https://docs.aws.amazon.com/ses/latest/APIReference/API_ConfigurationSet.html)和消息标签。

有关使用 Amazon SES API 的更多信息，请参阅 [Amazon Simple Email Service API 参考](https://docs.aws.amazon.com/ses/latest/APIReference/)。

## 使用特定于 Amazon SES 的电子邮件标头
<a name="event-publishing-using-ses-headers"></a>

在使用 `SendRawEmail` 或 SMTP 接口时，您可以通过将特定于 Amazon SES 的标头添加到电子邮件来指定配置集和邮件标签。Amazon SES 将删除标头，然后再发送电子邮件。下表显示了要使用的标头的名称。


| 事件发布信息 | 标题 | 
| --- | --- | 
|  配置集  |  `X-SES-CONFIGURATION-SET`  | 
|  邮件标签  |  `X-SES-MESSAGE-TAGS`  | 

以下示例显示了在提交至 Amazon SES 的原始电子邮件中标头的具体形式。

```
 1. X-SES-MESSAGE-TAGS: tagName1=tagValue1, tagName2=tagValue2
 2. X-SES-CONFIGURATION-SET: myConfigurationSet
 3. From: sender@example.com
 4. To: recipient@example.com
 5. Subject: Subject
 6. Content-Type: multipart/alternative;
 7. 	boundary="----=_boundary"
 8. 
 9. ------=_boundary
10. Content-Type: text/plain; charset=UTF-8
11. Content-Transfer-Encoding: 7bit
12. 
13. body
14. ------=_boundary
15. Content-Type: text/html; charset=UTF-8
16. Content-Transfer-Encoding: 7bit
17. 
18. body
19. ------=_boundary--
```

## 使用自定义电子邮件标头
<a name="event-publishing-using-custom-headers"></a>

尽管您必须使用特定于 Amazon SES 的标头 `X-SES-CONFIGURATION-SET` 指定配置集名称，但您可以使用自己的 MIME 标头指定邮件标签。

**注意**  
Amazon SES 事件发布使用的标头名称和值必须是 ASCII 码。如果您为 Amazon SES 事件发布指定非 ASCII 标头名称或值，则电子邮件发送调用仍会成功，但不会向亚马逊发送事件指标。 CloudWatch