

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 為 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`SendTemplatedEmail`，您可以選擇三種電子郵件傳送動作之一：`SendEmail`、 和 `SendRawEmail`。[Amazon Simple Email Service API 參考資料](https://docs.aws.amazon.com/ses/latest/APIReference/)中說明了這些 API 的詳細資訊，但我們在此提供的是傳送授權參數的概觀。

### 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_tw/ses/latest/dg/sending-authorization-delegate-sender-tasks-email.html)
+ **在電子郵件中加入 X 標頭**。X-標題為自訂標頭，是除了標準電子郵件標頭 (例如「寄件人」、「回覆至」或「主旨」標題) 外可用的另一選擇。Amazon SES 能辨識三種 X-標題，可用於指定傳送授權參數：
**重要**  
請勿在 DKIM 簽章中加入這些 X-標題，因為 Amazon SES 已在傳送電子郵件前將其移除。  
****    
[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/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-標題方法。


****  

| 參數 | Description | 
| --- | --- | 
| `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` 命令後傳遞這些標頭。