AWS SDK を使用して、Amazon SES でドメイン ID を検証する - AWS SDK コードサンプル

Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS GitHub

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS SDK を使用して、Amazon SES でドメイン ID を検証する

次のコード例は、Amazon SES でドメイン ID を検証する方法を示しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

CLI
AWS CLI

Amazon SES でドメインを検証するには

以下の例では、verify-domain-identity コマンドを使用してドメインを認証しています。

aws ses verify-domain-identity --domain example.com

出力:

{ "VerificationToken": "eoEmxw+YaYhb3h3iVJHuXMJXqeu1q1/wwmvjuEXAMPLE" }

ドメイン検証を完了するには、返された検証トークンと共に、TXT レコードをドメインの DNS 設定に追加する必要があります。詳細については、「Amazon Simple Email Service デベロッパーガイド」の「Amazon SES でのドメインの検証」を参照してください。

  • API の詳細については、「 コマンドリファレンスVerifyDomainIdentity」の「」を参照してください。 AWS CLI

JavaScript
SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

import { VerifyDomainIdentityCommand } from "@aws-sdk/client-ses"; import { getUniqueName, postfix, } from "@aws-sdk-examples/libs/utils/util-string.js"; import { sesClient } from "./libs/sesClient.js"; /** * You must have access to the domain's DNS settings to complete the * domain verification process. */ const DOMAIN_NAME = postfix(getUniqueName("Domain"), ".example.com"); const createVerifyDomainIdentityCommand = () => { return new VerifyDomainIdentityCommand({ Domain: DOMAIN_NAME }); }; const run = async () => { const VerifyDomainIdentityCommand = createVerifyDomainIdentityCommand(); try { return await sesClient.send(VerifyDomainIdentityCommand); } catch (err) { console.log("Failed to verify domain.", err); return err; } };
  • API の詳細については、「 API リファレンスVerifyDomainIdentity」の「」を参照してください。 AWS SDK for JavaScript

Python
SDK for Python (Boto3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

class SesIdentity: """Encapsulates Amazon SES identity functions.""" def __init__(self, ses_client): """ :param ses_client: A Boto3 Amazon SES client. """ self.ses_client = ses_client def verify_domain_identity(self, domain_name): """ Starts verification of a domain identity. To complete verification, you must create a TXT record with a specific format through your DNS provider. For more information, see *Verifying a domain with Amazon SES* in the Amazon SES documentation: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domain-procedure.html :param domain_name: The name of the domain to verify. :return: The token to include in the TXT record with your DNS provider. """ try: response = self.ses_client.verify_domain_identity(Domain=domain_name) token = response["VerificationToken"] logger.info("Got domain verification token for %s.", domain_name) except ClientError: logger.exception("Couldn't verify domain %s.", domain_name) raise else: return token
  • API の詳細については、VerifyDomainIdentityAWS「 SDK for Python (Boto3) API リファレンス」の「」を参照してください。