Use GetIdentityVerificationAttributes with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetIdentityVerificationAttributes with an AWS SDK or CLI

The following code examples show how to use GetIdentityVerificationAttributes.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

.NET
AWS SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/// <summary> /// Get identity verification status for an email. /// </summary> /// <returns>The verification status of the email.</returns> public async Task<VerificationStatus> GetIdentityStatusAsync(string email) { var result = VerificationStatus.TemporaryFailure; try { var response = await _amazonSimpleEmailService.GetIdentityVerificationAttributesAsync( new GetIdentityVerificationAttributesRequest { Identities = new List<string> { email } }); if (response.VerificationAttributes.ContainsKey(email)) result = response.VerificationAttributes[email].VerificationStatus; } catch (Exception ex) { Console.WriteLine("GetIdentityStatusAsync failed with exception: " + ex.Message); } return result; }
CLI
AWS CLI

To get the Amazon SES verification status for a list of identities

The following example uses the get-identity-verification-attributes command to retrieve the Amazon SES verification status for a list of identities:

aws ses get-identity-verification-attributes --identities "user1@example.com" "user2@example.com"

Output:

{ "VerificationAttributes": { "user1@example.com": { "VerificationStatus": "Success" }, "user2@example.com": { "VerificationStatus": "Pending" } } }

If you call this command with an identity that you have never submitted for verification, that identity won't appear in the output.

For more information about verified identities, see Verifying Email Addresses and Domains in Amazon SES in the Amazon Simple Email Service Developer Guide.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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 get_identity_status(self, identity): """ Gets the status of an identity. This can be used to discover whether an identity has been successfully verified. :param identity: The identity to query. :return: The status of the identity. """ try: response = self.ses_client.get_identity_verification_attributes( Identities=[identity] ) status = response["VerificationAttributes"].get( identity, {"VerificationStatus": "NotFound"} )["VerificationStatus"] logger.info("Got status of %s for %s.", status, identity) except ClientError: logger.exception("Couldn't get status for %s.", identity) raise else: return status
Ruby
SDK for Ruby
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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 puts email if status == 'Success' end