

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

# 步骤 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（大写和小写字母）、连字符（-）和下划线（\_）。

## 使用 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