翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK VerifyDomainIdentity
またはコマンドラインツールと併用してください。
次のコード例は使用方法を示していますVerifyDomainIdentity
。
アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。
- 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 でのドメインの検証」を参照してください。
- JavaScript
-
- JavaScript (v3) 用 SDK
-
import { VerifyDomainIdentityCommand } from "@aws-sdk/client-ses";
import {
getUniqueName,
postfix,
} from "@aws-doc-sdk-examples/lib/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;
}
};
- Python
-
- SDK for Python (Boto3)
-
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
AWS SDK 開発者ガイドとコード例の完全なリストについては、を参照してください。AWS SDK での Amazon SES の使用このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。