または VerifyEmailIdentityAWS SDKで を使用する CLI - AWS SDK コード例

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

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

または VerifyEmailIdentityAWS SDKで を使用する CLI

以下のコード例は、VerifyEmailIdentity の使用方法を示しています。

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

.NET
AWS SDK for .NET
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

/// <summary> /// Starts verification of an email identity. This request sends an email /// from Amazon SES to the specified email address. To complete /// verification, follow the instructions in the email. /// </summary> /// <param name="recipientEmailAddress">Email address to verify.</param> /// <returns>True if successful.</returns> public async Task<bool> VerifyEmailIdentityAsync(string recipientEmailAddress) { var success = false; try { var response = await _amazonSimpleEmailService.VerifyEmailIdentityAsync( new VerifyEmailIdentityRequest { EmailAddress = recipientEmailAddress }); success = response.HttpStatusCode == HttpStatusCode.OK; } catch (Exception ex) { Console.WriteLine("VerifyEmailIdentityAsync failed with exception: " + ex.Message); } return success; }
  • API 詳細については、「 リファレンスVerifyEmailIdentity」の「」を参照してください。 AWS SDK for .NET API

C++
SDK C++ 用
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

//! Add an email address to the list of identities associated with this account and //! initiate verification. /*! \param emailAddress; The email address to add. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::verifyEmailIdentity(const Aws::String &emailAddress, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::VerifyEmailIdentityRequest verifyEmailIdentityRequest; verifyEmailIdentityRequest.SetEmailAddress(emailAddress); Aws::SES::Model::VerifyEmailIdentityOutcome outcome = sesClient.VerifyEmailIdentity(verifyEmailIdentityRequest); if (outcome.IsSuccess()) { std::cout << "Email verification initiated." << std::endl; } else { std::cerr << "Error initiating email verification. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • API 詳細については、「 リファレンスVerifyEmailIdentity」の「」を参照してください。 AWS SDK for C++ API

CLI
AWS CLI

Amazon で E メールアドレスを検証するには SES

以下の例では、verify-email-identity コマンドを使用して E メールアドレスを認証しています。

aws ses verify-email-identity --email-address user@example.com

Amazon を使用して E メールを送信する前にSES、E メールを送信するアドレスまたはドメインを確認して、E メールを所有していることを証明する必要があります。本番稼働用アクセスがまだない場合は、Amazon SESメールボックスシミュレーターから提供された E メールアドレスを除き、E メールを送信する E メールアドレスも検証する必要があります。

verify-email-identity が呼び出されると、E メールアドレスに検証 E メールが送信されます。ユーザーは、E メールのリンクをクリックして、検証プロセスを完了する必要があります。

詳細については、Amazon Simple Email Service デベロッパーガイドの「Amazon SESでの E メールアドレスの検証」を参照してください。

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

JavaScript
SDK JavaScript (v3) 用の
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

// Import required AWS SDK clients and commands for Node.js import { VerifyEmailIdentityCommand } from "@aws-sdk/client-ses"; import { sesClient } from "./libs/sesClient.js"; const EMAIL_ADDRESS = "name@example.com"; const createVerifyEmailIdentityCommand = (emailAddress) => { return new VerifyEmailIdentityCommand({ EmailAddress: emailAddress }); }; const run = async () => { const verifyEmailIdentityCommand = createVerifyEmailIdentityCommand(EMAIL_ADDRESS); try { return await sesClient.send(verifyEmailIdentityCommand); } catch (err) { console.log("Failed to verify email identity.", err); return err; } };
  • API 詳細については、「 リファレンスVerifyEmailIdentity」の「」を参照してください。 AWS SDK for JavaScript API

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_email_identity(self, email_address): """ Starts verification of an email identity. This function causes an email to be sent to the specified email address from Amazon SES. To complete verification, follow the instructions in the email. :param email_address: The email address to verify. """ try: self.ses_client.verify_email_identity(EmailAddress=email_address) logger.info("Started verification of %s.", email_address) except ClientError: logger.exception("Couldn't start verification of %s.", email_address) raise
  • API 詳細については、VerifyEmailIdentity「 for AWS SDK Python (Boto3) APIリファレンス」の「」を参照してください。

Ruby
SDK Ruby 用
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

require "aws-sdk-ses" # v2: require 'aws-sdk' # Replace recipient@example.com with a "To" address. recipient = "recipient@example.com" # Create a new SES resource in the us-west-2 region. # Replace us-west-2 with the AWS Region you're using for Amazon SES. ses = Aws::SES::Client.new(region: "us-west-2") # Try to verify email address. begin ses.verify_email_identity({ email_address: recipient }) puts "Email sent to " + recipient # If something goes wrong, display an error message. rescue Aws::SES::Errors::ServiceError => error puts "Email not sent. Error message: #{error}" end
  • API 詳細については、「 リファレンスVerifyEmailIdentity」の「」を参照してください。 AWS SDK for Ruby API