Utilizzare VerifyDomainIdentity con un o AWS SDK CLI - Esempi di codice dell'AWS SDK

Ci sono altri AWS SDK esempi disponibili nel repository AWS Doc SDK Examples GitHub .

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à.

Utilizzare VerifyDomainIdentity con un o AWS SDK CLI

I seguenti esempi di codice mostrano come utilizzareVerifyDomainIdentity.

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

CLI
AWS CLI

Per verificare un dominio con Amazon SES

Nell'esempio seguente viene utilizzato il comando verify-domain-identity per verificare un dominio:

aws ses verify-domain-identity --domain example.com

Output:

{ "VerificationToken": "eoEmxw+YaYhb3h3iVJHuXMJXqeu1q1/wwmvjuEXAMPLE" }

Per completare la verifica del dominio, devi aggiungere un TXT record con il token di verifica restituito alle DNS impostazioni del dominio. Per ulteriori informazioni, consulta Verifying Domains in Amazon SES nella Amazon Simple Email Service Developer Guide.

JavaScript
SDKper JavaScript (v3)
Nota

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

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
SDKper Python (Boto3)
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.

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