View a markdown version of this page

設定租戶層級禁止 - Amazon Simple Email Service

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

設定租戶層級禁止

設定租戶層級禁止設定,以控制 Amazon Simple Email Service (Amazon SES) 如何處理個別租戶的退信和投訴。根據預設,租戶會使用您的帳戶層級禁止名單。當您啟用租用戶層級禁止時,SES 會維護每個租用戶的個別禁止名單。這可讓您精細控制電子郵件可交付性。

本主題提供使用 啟用、修改、停用和檢視租用戶層級禁止設定的程序 AWS CLI。

重要

停用租戶層級禁止不會從租戶禁止名單中刪除現有項目。如果您稍後重新啟用租用戶層級禁止,這些項目仍會處於作用中狀態。

先決條件

設定租戶層級禁止之前,請確定您符合下列要求:

啟用現有租用戶的租用戶層級禁止

使用 PutTenantSuppressionAttributes API 操作來啟用現有租用戶的租用戶層級禁止。此操作是等冪的,因此您可以使用相同的參數多次呼叫它,而不會產生副作用。

啟用租戶層級禁止
  1. 在命令列,執行下列put-tenant-suppression-attributes命令來啟用退信和投訴的租戶層級抑制:

    Linux, macOS, or Unix
    aws sesv2 put-tenant-suppression-attributes \ --tenant-name MyTenant \ --suppression-scope TENANT \ --suppressed-reasons BOUNCE COMPLAINT
    Windows
    aws sesv2 put-tenant-suppression-attributes ` --tenant-name MyTenant ` --suppression-scope TENANT ` --suppressed-reasons BOUNCE COMPLAINT

    將 MyTenant 取代為您的租用戶名稱。

  2. 確認命令未傳回任何輸出。成功的請求會傳回沒有內文的 HTTP 200 回應。

  3. 執行下列命令來確認組態:

    aws sesv2 get-tenant --tenant-name MyTenant

租戶現在會針對退信和投訴使用自己的禁止名單。

您也可以為單一原因類型設定抑制。下列範例示範如何僅針對退信或投訴啟用抑制。

下列命令只會抑制退信:

Linux, macOS, or Unix
aws sesv2 put-tenant-suppression-attributes \ --tenant-name MyTenant \ --suppression-scope TENANT \ --suppressed-reasons BOUNCE
Windows
aws sesv2 put-tenant-suppression-attributes ` --tenant-name MyTenant ` --suppression-scope TENANT ` --suppressed-reasons BOUNCE

下列命令只會抑制投訴:

Linux, macOS, or Unix
aws sesv2 put-tenant-suppression-attributes \ --tenant-name MyTenant \ --suppression-scope TENANT \ --suppressed-reasons COMPLAINT
Windows
aws sesv2 put-tenant-suppression-attributes ` --tenant-name MyTenant ` --suppression-scope TENANT ` --suppressed-reasons COMPLAINT
注意

您必須--suppressed-reasons一併提供 --suppression-scope和 。在沒有另一個 的情況下提供一個 會傳回 InvalidParameterValueException。

建立新租用戶時設定禁止

使用 CreateTenant API 操作搭配 SuppressionAttributes 參數,從一開始就建立已啟用租用戶層級禁止的租用戶。

建立具有租用戶層級禁止的租用戶
  1. 在命令列中,執行下列create-tenant命令:

    Linux, macOS, or Unix
    aws sesv2 create-tenant \ --tenant-name MyNewTenant \ --suppression-attributes '{"SuppressionScope":"TENANT","SuppressedReasons":["BOUNCE","COMPLAINT"]}'
    Windows
    aws sesv2 create-tenant ` --tenant-name MyNewTenant ` --suppression-attributes '{"SuppressionScope":"TENANT","SuppressedReasons":["BOUNCE","COMPLAINT"]}'

    使用新租用戶的名稱取代 MyNewTenant。

  2. 確認回應包含租戶 ID:

    { "TenantId": "tn-abc123def456" }

租用戶的建立會同時啟用退信和投訴的租用戶層級抑制。

注意

如果您省略 --suppression-attributes,租戶會預設為ACCOUNT範圍 ,並使用帳戶層級禁止名單。

使用組態集覆寫租戶禁止

您可以將 SuppressionScope新增至組態集的 ,以覆寫租戶的禁止設定SuppressionOptions。當您使用此組態集傳送電子郵件時,組態集的禁止設定優先於租戶的設定。您只能覆寫範圍、僅限原因,或同時覆寫兩者。

建立具有租用戶範圍覆寫的組態設定
  1. 在命令列中,執行下列create-configuration-set命令:

    Linux, macOS, or Unix
    aws sesv2 create-configuration-set \ --configuration-set-name my-config-set \ --suppression-options '{"SuppressionScope":"TENANT","SuppressedReasons":["BOUNCE"]}'
    Windows
    aws sesv2 create-configuration-set ` --configuration-set-name my-config-set ` --suppression-options '{"SuppressionScope":"TENANT","SuppressedReasons":["BOUNCE"]}'

    以組態my-config-setset。

  2. 確認命令未傳回任何輸出。成功的請求會傳回 HTTP 200 回應。

使用禁止選項更新現有的組態設定
  1. 在命令列中,執行下列put-configuration-set-suppression-options命令:

    Linux, macOS, or Unix
    aws sesv2 put-configuration-set-suppression-options \ --configuration-set-name my-config-set \ --suppression-scope TENANT \ --suppressed-reasons BOUNCE
    Windows
    aws sesv2 put-configuration-set-suppression-options ` --configuration-set-name my-config-set ` --suppression-scope TENANT ` --suppressed-reasons BOUNCE

    以組態集的名稱取代 my-config-setset。

  2. 確認命令未傳回任何輸出。成功的請求會傳回 HTTP 200 回應。

停用租戶層級禁止

若要將租戶傳回帳戶層級禁止,您可以將範圍設定為 ACCOUNT 或清除所有禁止設定。

將租戶設定為帳戶層級禁止
  1. 在命令列中,執行下列命令,將範圍明確設定為 ACCOUNT:

    Linux, macOS, or Unix
    aws sesv2 put-tenant-suppression-attributes \ --tenant-name MyTenant \ --suppression-scope ACCOUNT \ --suppressed-reasons BOUNCE COMPLAINT
    Windows
    aws sesv2 put-tenant-suppression-attributes ` --tenant-name MyTenant ` --suppression-scope ACCOUNT ` --suppressed-reasons BOUNCE COMPLAINT

    將 MyTenant 取代為您的租用戶名稱。

  2. 確認命令未傳回任何輸出。

清除所有禁止設定
  1. 在命令列中,執行下列命令,而不指定範圍或原因:

    aws sesv2 put-tenant-suppression-attributes --tenant-name MyTenant

    將 MyTenant 取代為您的租用戶名稱。

  2. 確認命令未傳回任何輸出。

注意

當您省略 --suppression-scope和 時--suppressed-reasons,SES 會清除租戶的禁止設定。租用戶會回到帳戶層級的禁止行為。

重要

停用租戶層級禁止不會從租戶禁止名單中刪除現有項目。如果您稍後重新啟用租用戶層級禁止,這些項目仍會處於作用中狀態。

檢視目前的禁止組態

使用 GetTenant API 操作來檢查租用戶目前的禁止設定。

檢視租戶的禁止組態
  1. 在命令列中,執行下列get-tenant命令:

    aws sesv2 get-tenant --tenant-name MyTenant

    將 MyTenant 取代為您的租用戶名稱。

  2. 檢閱回應。下列範例顯示已啟用租用戶層級禁止的租用戶:

    { "Tenant": { "TenantName": "MyTenant", "TenantId": "tn-abc123def456", "TenantArn": "arn:aws:ses:us-east-1:123456789012:tenant/MyTenant/tn-abc123def456", "SendingStatus": "ENABLED", "CreatedTimestamp": 1705312800, "UpdateTimestamp": 1705762800, "SuppressionAttributes": { "SuppressionScope": "TENANT", "SuppressedReasons": ["BOUNCE", "COMPLAINT"] } } }

下表說明 SuppressionAttributes 物件中的金鑰欄位。

欄位 說明
SuppressionScope 租用戶的禁止範圍。的值TENANT表示租戶使用自己的禁止名單。的值ACCOUNT表示租戶使用帳戶層級禁止名單。
SuppressedReasons 租用戶作用中的禁止原因。可能的值為 BOUNCE、 COMPLAINT或兩者。

如果 回應中不存在或SuppressionAttributes為 null,則租戶會使用帳戶層級禁止。

疑難排解

以下是您在設定租用戶層級禁止時可能遇到的常見錯誤。

InvalidParameterValueException: SuppressedReasons cannot be null when SuppressionScope is provided
  • 原因 – 您指定的--suppression-scope沒有 --suppressed-reasons。

  • 修正 – 同時提供兩個參數,或省略這兩個參數以清除設定。

InvalidParameterValueException: SuppressionScope is required when SuppressedReasons are provided
  • 原因 – 您指定的--suppressed-reasons沒有 --suppression-scope。

  • 修正 – 同時提供兩個參數。

NotFoundException
  • 原因 – 您指定的租戶名稱不存在。

  • 修正 – 執行下列命令來驗證租用戶名稱:

    aws sesv2 list-tenants