

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

# Amazon SES 发送授权的委托发件人任务
<a name="sending-authorization-delegate-sender-tasks"></a>

作为委托发件人，您将代表不属于自己但已获得使用授权的身份发送电子邮件。即使您代表身份所有者发送，退回邮件和投诉也会计入您 AWS 账户的退回和投诉指标，您发送的消息数量也计入您的发送配额。如果发送身份拥有者的电子邮件时需要提出发送配额提升申请，该申请也由您负责提交。

作为委托发件人，您必须完成以下任务：
+ [向身份拥有者提供信息](sending-authorization-delegate-sender-tasks-information.md)
+ [使用委托发件人通知](sending-authorization-delegate-sender-tasks-notifications.md)
+ [代表身份拥有者发送电子邮件](sending-authorization-delegate-sender-tasks-email.md)

# 向 Amazon SES 发送授权的身份拥有者提供信息
<a name="sending-authorization-delegate-sender-tasks-information"></a>

作为委托发件人，您必须向身份所有者提供您的 AWS 账户 ID 或 IAM 用户的 Amazon 资源名称 (ARN)，因为您将代表身份所有者发送电子邮件。身份所有者需要您的账户信息，这样他就可以创建一个策略，授予您从其验证身份之一发送的权限。

如果您想使用自己的 SNS 主题，可以请求身份所有者配置反馈通知，以便发送到一个或多个 SNS 主题的退回、投诉或交付。执行此操作，您需要与身份所有者共享 SNS 主题 ARN，以便其可以在授权您发送的已验证身份中配置您的 SNS 主题。

以下步骤说明了如何查找您的账户信息以及要与您的身份所有者共享的 SNS 主题 ARNs 。

**要查找您的 AWS 账户 ID**

1. 登录到 a AWS 管理控制台 t [https://console.aws.amazon.com](https://console.aws.amazon.com/)。

1. 在控制台的右上角，展开您的 name/account 电话号码，然后在下拉列表中选择 “**我的账户**”。

1. 账户设置页面将打开并显示您的所有账户信息，包括您的 AWS 账户 ID。

**要查找您的 IAM 用户 ARN**

1. 登录 AWS 管理控制台 并打开 IAM 控制台，网址为[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)。

1. 在导航窗格中，选择 **Users**（用户）。

1. 在用户列表中，选择用户名。**Summary** 部分将显示 IAM 用户 ARN。ARN 与以下示例类似：*arn:aws:iam::123456789012:user/John*。

**要查找您的 SNS 主题 ARN**

1. [在 v3/home 上打开亚马逊 SNS 控制台。https://console.aws.amazon.com/sns/](https://console.aws.amazon.com/sns/v3/home)

1. 在导航窗格中，选择**主题**。

1. 在主题列表中，SNS 主题显示 ARNs 在 AR **N** 列中。ARN 类似于以下示例：arn: aws: sns: us-east-1 *:4444555566* 66:。my-sns-topic

# 使用 Amazon SES 发送授权的身份拥有者通知
<a name="sending-authorization-delegate-sender-tasks-notifications"></a>

作为跨账户电子邮件的委托发件人，您代表您未拥有但已获得授权使用的身份发送电子邮件；但是，退回邮件和投诉仍然计入*您的*退回邮件和投诉指标，而不是身份拥有者的指标。

如果账户的邮件退回率或投诉率过高，则您的账户有被审核的风险，或其发送电子邮件的功能将被暂停。因此，设置通知并制定流程来监控它们十分重要。您还需要建立一套流程从邮件列表中删除已退回或遭投诉的地址。

因此，作为委托发件人，您可以将 Amazon SES 配置为在您代表您未拥有但经身份拥有者授权使用的任何身份发送的电子邮件发生退回邮件和投诉事件时发送通知。您还可以设置[事件发布](monitor-using-event-publishing.md)以将退回邮件和投诉通知发布到 Amazon SNS 或 Firehose。

**注意**  
如果将 Amazon SES 设置为使用 Amazon SNS 发送通知，则按标准 Amazon SNS 费率收取所接收通知的费用。有关更多信息，请参阅 [Amazon SNS 定价页面](https://aws.amazon.com/sns/pricing)。

## 创建新的委托发件人通知
<a name="sending-authorization-delegate-sender-tasks-management-add"></a>

您可以通过使用[事件发布](event-destinations-manage.md)的配置集，或使用[配置了您自己的 SNS 主题](sending-authorization-identity-owner-tasks-policy.md#configure-sns-topic-you-dont-own)的经验证身份来设置委托发送通知。

下面给出了使用任何一种方法设置新的委托发送通知的过程：
+ 通过配置集进行事件发布
+ 针对您拥有的 SNS 主题的反馈通知

**通过代表发送的配置集设置事件发布**

1. 登录 AWS 管理控制台 并打开 Amazon SES 控制台，网址为[https://console.aws.amazon.com/ses/](https://console.aws.amazon.com/ses/)。

1. 按照 [创建事件目标](event-destinations-manage.md) 所述的过程操作。

1. 在配置集中设置事件发布后，当您使用身份所有者授权您发送的经验证的身份以委托发件人身份发送电子邮件时，指定配置集的名称。请参阅[代表身份拥有者发送电子邮件](sending-authorization-delegate-sender-tasks-email.md)。

**为代表发送的 SNS 主题设置反馈通知**

1. 在决定要用于反馈通知的 SNS 主题之后，请按照以下步骤操作[查找您的 SNS 主题 ARN](sending-authorization-delegate-sender-tasks-information.md#find-sns-topic-arn)，然后复制完整的 ARN 并与身份所有者共享。

1. 要求身份所有者配置 SNS 主题，以获得有关他授权发送的共享身份的反馈通知。（您的身份所有者将需要遵循在授权策略过程中 [configuring SNS topics](sending-authorization-identity-owner-tasks-policy.md#configure-sns-topic-you-dont-own)（配置 SNS 主题）的过程）。

# 使用 Amazon SES 发送授权代表身份拥有者发送电子邮件
<a name="sending-authorization-delegate-sender-tasks-email"></a>

作为委托发件人，您发送电子邮件的方式与其他 Amazon SES 发件人相同，不同的是，您需要提供身份拥有者已授权您使用的身份的 Amazon Resource Name (ARN)。当您调用 Amazon SES 来发送电子邮件时，Amazon SES 会检查您指定的身份是否包含授权您发送电子邮件的策略。

有几种不同的方法可用于指定在发送电子邮件时的身份的 ARN。您使用的方法取决于您是使用 Amazon SES API 操作还是 Amazon SES SMTP 接口来发送电子邮件。

**重要**  
要成功发送电子邮件，您必须连接到身份所有者验证身份的 AWS 区域中的 Amazon SES 终端节点。
**此外，必须先将身份所有者和委托发件人的 AWS 账户从沙箱中删除，然后两个账户才能向未经验证的地址发送电子邮件。**有关更多信息，请参阅 [请求生产访问权限（从 Amazon SES 沙盒中移出）](request-production-access.md)。
如果您被授权使用的身份在次要区域中复制，作为[全局端点](global-endpoints.md)功能的一部分：  
身份所有者应该向您提供了一个身份 ARN，其中区域参数（例如 `us-east-1`）被替换为星号 `*`，如以下示例 `arn:aws:ses:*:123456789012:identity/user@example.com` 所示。
身份所有者应该已经在主要区域和次要区域为您创建了发送授权策略。

## 使用 Amazon SES API
<a name="sending-authorization-delegate-sender-tasks-api"></a>

与任何 Amazon SES 电子邮件发件人一样，如果您通过 Amazon SES API（直接通过 HTTPS 或间接通过 AWS SDK）访问 Amazon SES，则可以在三种电子邮件发送操作中进行选择：`SendEmail``SendTemplatedEmail`、和。`SendRawEmail`[Amazon Simple Email Service API 参考](https://docs.aws.amazon.com/ses/latest/APIReference/)详细介绍了这些参数 APIs，但我们在此处提供了发送授权参数的概述。

### SendRawEmail
<a name="sending-authorization-delegate-sender-tasks-api-sendrawemail"></a>

如果您想要使用 `SendRawEmail` 以便可以控制电子邮件的格式，您可以通过以下两种方式之一指定委托授权身份：
+ **向 `SendRawEmail` API 传递可选参数**。下表中描述了必需参数：  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/ses/latest/dg/sending-authorization-delegate-sender-tasks-email.html)
+ **在电子邮件中包括 X 标头**。X 标头是自定义标头，可以作为标准电子邮件标头的补充来使用（例如 From、Reply-To 或 Subject 标头）。Amazon SES 能识别三种 X 标头，您可以用它们来指定发送授权参数：
**重要**  
请不要在 DKIM 签名中包含这些 X 标头，因为它们将在发送电子邮件之前被 Amazon SES 删除。  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/ses/latest/dg/sending-authorization-delegate-sender-tasks-email.html)

  Amazon SES 会从电子邮件中删除所有 X 标头，然后再发送。如果电子邮件中包含 X 标头的多个实例，则 Amazon SES 仅使用第一个实例。

  以下示例显示了一封包含发送授权 X 标头的电子邮件：

  ```
   1. X-SES-SOURCE-ARN: arn:aws:ses:us-east-1:123456789012:identity/example.com
   2. X-SES-FROM-ARN: arn:aws:ses:us-east-1:123456789012:identity/example.com
   3. X-SES-RETURN-PATH-ARN: arn:aws:ses:us-east-1:123456789012:identity/example.com
   4. 
   5. From: sender@example.com
   6. To: recipient@example.com
   7. Return-Path: feedback@example.com
   8. Subject: subject
   9. Content-Type: multipart/alternative;
  10. 	boundary="----=_boundary"
  11. 
  12. ------=_boundary
  13. Content-Type: text/plain; charset=UTF-8
  14. Content-Transfer-Encoding: 7bit
  15. 
  16. body
  17. ------=_boundary
  18. Content-Type: text/html; charset=UTF-8
  19. Content-Transfer-Encoding: 7bit
  20. 
  21. body
  22. ------=_boundary--
  ```

### SendEmail 和 SendTemplatedEmail
<a name="sending-authorization-delegate-sender-tasks-api-sendemail"></a>

如果您使用 `SendEmail` 或 `SendTemplatedEmail` 操作，则可以通过传入下面的可选参数来指定委托的授权身份。使用 `SendEmail` 或 `SendTemplatedEmail` 操作时，不能使用 X 标头方法。


****  

| 参数 | 说明 | 
| --- | --- | 
| `SourceArn` | 与发送授权策略相关联的身份的 ARN 允许您使用在 `SendEmail` 或 `SendTemplatedEmail` 的 `Source` 参数中指定的电子邮件地址发送电子邮件。 | 
| `ReturnPathArn` | 与发送授权策略相关联的身份的 ARN 允许您使用在 `SendEmail` 或 `SendTemplatedEmail` 的 `ReturnPath` 参数中指定的电子邮件地址。 | 

以下示例显示如何使用 `SendEmail` 或 `SendTemplatedEmail` 操作和[适用于 Python 的 SDK](https://aws.amazon.com/sdk-for-python) 来发送包含 `SourceArn` 和 `ReturnPathArn` 属性的电子邮件。

```
import boto3
from botocore.exceptions import ClientError

# Create a new SES resource and specify a region.
client = boto3.client('ses',region_name="us-east-1")

# Try to send the email.
try:
    #Provide the contents of the email.
    response = client.send_email(
        Destination={
            'ToAddresses': [
                'recipient@example.com',
            ],
        },
        Message={
            'Body': {
                'Html': {
                    'Charset': 'UTF-8',
                    'Data': 'This email was sent with Amazon SES.',
                },
            },
            'Subject': {
                'Charset': 'UTF-8',
                'Data': 'Amazon SES Test',
            },
        },
        SourceArn='arn:aws:ses:us-east-1:123456789012:identity/example.com',
        ReturnPathArn='arn:aws:ses:us-east-1:123456789012:identity/example.com',
        Source='sender@example.com',
        ReturnPath='feedback@example.com'
    )
# Display an error if something goes wrong.	
except ClientError as e:
    print(e.response['Error']['Message'])
else:
    print("Email sent! Message ID:"),
    print(response['ResponseMetadata']['RequestId'])
```

## 使用 Amazon SES SMTP 接口
<a name="sending-authorization-delegate-sender-tasks-smtp"></a>

使用 Amazon SES SMTP 接口进行委托发送时，必须在邮件中包含 `X-SES-SOURCE-ARN`、`X-SES-FROM-ARN` 和 `X-SES-RETURN-PATH-ARN` 标头。在 SMTP 会话中发出 `DATA` 命令后将传递这些标头。