Utilizzo GetIdentityVerificationAttributes con un AWS SDK o una CLI - Amazon Simple Email Service

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Utilizzo GetIdentityVerificationAttributes con un AWS SDK o una CLI

I seguenti esempi di codice mostrano come utilizzareGetIdentityVerificationAttributes.

Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:

.NET
AWS SDK for .NET
Nota

C'è altro su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

/// <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

Ottenere lo stato di verifica di Amazon SES per un elenco di identità

Nell'esempio seguente viene utilizzato il comando get-identity-verification-attributes per richiamare lo stato di verifica di Amazon SES per un elenco di identità:

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" } } }

Se chiami questo comando con un'identità che non hai mai inviato per la verifica, tale identità non verrà visualizzata nell'output.

Per ulteriori informazioni riguardo alle identità verificate, consulta Verifica degli indirizzi e-mail e dei domini in Amazon SES nella Guida per gli sviluppatori di Amazon Simple Email Service.

Python
SDK per Python (Boto3)
Nota

C'è altro su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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 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 per Ruby
Nota

C'è di più su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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

Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, consultaUtilizzo di Amazon SES con un AWS SDK. Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell'SDK.