AWS SDK 또는 ListIdentities CLI와 함께 사용 - Amazon Simple Email Service

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK 또는 ListIdentities CLI와 함께 사용

다음 코드 예제는 ListIdentities의 사용 방법을 보여줍니다.

작업 예시는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.

.NET
AWS SDK for .NET
참고

더 많은 정보가 있습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

/// <summary> /// Get the identities of a specified type for the current account. /// </summary> /// <param name="identityType">IdentityType to list.</param> /// <returns>The list of identities.</returns> public async Task<List<string>> ListIdentitiesAsync(IdentityType identityType) { var result = new List<string>(); try { var response = await _amazonSimpleEmailService.ListIdentitiesAsync( new ListIdentitiesRequest { IdentityType = identityType }); result = response.Identities; } catch (Exception ex) { Console.WriteLine("ListIdentitiesAsync failed with exception: " + ex.Message); } return result; }
  • API 세부 정보는 AWS SDK for .NET API ListIdentities참조를 참조하십시오.

C++
SDK for C++
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

//! List the identities associated with this account. /*! \param identityType: The identity type enum. "NOT_SET" is a valid option. \param identities; A vector to receive the retrieved identities. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::listIdentities(Aws::SES::Model::IdentityType identityType, Aws::Vector<Aws::String> &identities, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::ListIdentitiesRequest listIdentitiesRequest; if (identityType != Aws::SES::Model::IdentityType::NOT_SET) { listIdentitiesRequest.SetIdentityType(identityType); } Aws::String nextToken; // Used for paginated results. do { if (!nextToken.empty()) { listIdentitiesRequest.SetNextToken(nextToken); } Aws::SES::Model::ListIdentitiesOutcome outcome = sesClient.ListIdentities( listIdentitiesRequest); if (outcome.IsSuccess()) { const auto &retrievedIdentities = outcome.GetResult().GetIdentities(); if (!retrievedIdentities.empty()) { identities.insert(identities.cend(), retrievedIdentities.cbegin(), retrievedIdentities.cend()); } nextToken = outcome.GetResult().GetNextToken(); } else { std::cout << "Error listing identities. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!nextToken.empty()); return true; }
  • API 세부 정보는 AWS SDK for C++ API ListIdentities참조를 참조하십시오.

CLI
AWS CLI

특정 AWS 계정의 모든 ID (이메일 주소 및 도메인) 를 나열하려면

다음 예제에서는 list-identities 명령을 사용하여 Amazon SES에 확인을 위해 제출된 모든 자격 증명을 나열합니다.

aws ses list-identities

출력:

{ "Identities": [ "user@example.com", "example.com" ] }

반환되는 목록에는 확인 상태(확인됨, 확인 보류 중, 실패 등)와 상관없이 모든 자격 증명이 포함됩니다.

이 예제에서는 자격 증명 유형 파라미터를 지정하지 않았으므로 이메일 주소와 도메인이 모두 반환됩니다.

확인에 대한 자세한 내용은 Amazon Simple Email Service 개발자 가이드에서 Amazon SES에서 이메일 주소 및 도메인 확인을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 ListIdentities참조를 참조하십시오.

Java
SDK for Java 2.x
참고

자세한 내용은 에서 확인할 수 GitHub 있습니다. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.ses.SesClient; import software.amazon.awssdk.services.ses.model.ListIdentitiesResponse; import software.amazon.awssdk.services.ses.model.SesException; import java.io.IOException; import java.util.List; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListIdentities { public static void main(String[] args) throws IOException { Region region = Region.US_WEST_2; SesClient client = SesClient.builder() .region(region) .build(); listSESIdentities(client); } public static void listSESIdentities(SesClient client) { try { ListIdentitiesResponse identitiesResponse = client.listIdentities(); List<String> identities = identitiesResponse.identities(); for (String identity : identities) { System.out.println("The identity is " + identity); } } catch (SesException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
  • API 세부 정보는 AWS SDK for Java 2.x API ListIdentities참조를 참조하십시오.

JavaScript
JavaScript (v3) 용 SDK
참고

더 많은 내용이 있습니다. GitHub AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

import { ListIdentitiesCommand } from "@aws-sdk/client-ses"; import { sesClient } from "./libs/sesClient.js"; const createListIdentitiesCommand = () => new ListIdentitiesCommand({ IdentityType: "EmailAddress", MaxItems: 10 }); const run = async () => { const listIdentitiesCommand = createListIdentitiesCommand(); try { return await sesClient.send(listIdentitiesCommand); } catch (err) { console.log("Failed to list identities.", err); return err; } };
  • API 세부 정보는 AWS SDK for JavaScript API ListIdentities참조를 참조하십시오.

PowerShell
다음을 위한 도구 PowerShell

예 1: 이 명령은 확인 상태와 상관없이 특정 AWS 계정의 모든 ID (이메일 주소 및 도메인) 가 포함된 목록을 반환합니다.

Get-SESIdentity
  • API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조를 참조하십시오 ListIdentities.

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 list_identities(self, identity_type, max_items): """ Gets the identities of the specified type for the current account. :param identity_type: The type of identity to retrieve, such as EmailAddress. :param max_items: The maximum number of identities to retrieve. :return: The list of retrieved identities. """ try: response = self.ses_client.list_identities( IdentityType=identity_type, MaxItems=max_items ) identities = response["Identities"] logger.info("Got %s identities for the current account.", len(identities)) except ClientError: logger.exception("Couldn't list identities for the current account.") raise else: return identities
  • API에 대한 자세한 내용은 파이썬용AWS SDK (Boto3) API 레퍼런스를 참조하십시오 ListIdentities.

Ruby
SDK for Ruby
참고

자세한 내용은 여기에서 확인할 수 있습니다. GitHub AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

require "aws-sdk-ses" # v2: require 'aws-sdk' # Create client in us-west-2 region # Replace us-west-2 with the AWS Region you're using for Amazon SES. client = Aws::SES::Client.new(region: "us-west-2") # Get up to 1000 identities ids = client.list_identities({ identity_type: "EmailAddress" }) ids.identities.each do |email| attrs = client.get_identity_verification_attributes({ identities: [email] }) status = attrs.verification_attributes[email].verification_status # Display email addresses that have been verified if status == "Success" puts email end end
  • API 세부 정보는 AWS SDK for Ruby API ListIdentities참조를 참조하십시오.

AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 을 참조하십시오AWS SDK와 함께 Amazon SES를 사용하기. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.