

 La [AWS SDK per JavaScript V3 API Reference Guide](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/) descrive in dettaglio tutte le operazioni API per la AWS SDK per JavaScript versione 3 (V3). 

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

# Gestione delle identità Amazon SES
<a name="ses-examples-managing-identities"></a>

![\[JavaScript code example that applies to Node.js execution\]](http://docs.aws.amazon.com/it_it/sdk-for-javascript/v3/developer-guide/images/nodeicon.png)

**Questo esempio di codice di Node.js illustra:**
+ Come verificare gli indirizzi e-mail e i domini utilizzati con Amazon SES.
+ Come assegnare una policy AWS Identity and Access Management (IAM) alle identità Amazon SES.
+ Come elencare tutte le identità Amazon SES per il tuo AWS account.
+ Come eliminare le identità utilizzate con Amazon SES.

Un'*identità* Amazon SES è un indirizzo e-mail o un dominio che Amazon SES utilizza per inviare e-mail. Amazon SES richiede che verifichi le tue identità e-mail, confermando che le possiedi e impedendo ad altri di utilizzarle.

Per dettagli su come verificare indirizzi e-mail e domini in Amazon SES, consulta la sezione [Verifica degli indirizzi e-mail e dei domini in Amazon SES nella Amazon Simple](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html) Email Service Developer Guide. Per informazioni sull'autorizzazione all'invio in Amazon SES, consulta [Panoramica dell'autorizzazione all'invio di Amazon SES](Amazon Simple Email Service Developer Guidesending-authorization-overview.html).

## Lo scenario
<a name="ses-examples-verifying-identities-scenario"></a>

In questo esempio, utilizzi una serie di moduli Node.js per verificare e gestire le identità di Amazon SES. I moduli Node.js utilizzano l'SDK per JavaScript verificare indirizzi e-mail e domini, utilizzando questi metodi della `SES` classe client:
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/ListIdentitiesCommand/](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/ListIdentitiesCommand/)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/DeleteIdentityCommand/](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/DeleteIdentityCommand/)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/VerifyEmailIdentityCommand/](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/VerifyEmailIdentityCommand/)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/VerifyDomainIdentityCommand/](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ses/Class/VerifyDomainIdentityCommand/)

## Attività prerequisite
<a name="ses-examples-verifying-identities-prerequisites"></a>

Per configurare ed eseguire questo esempio, è necessario completare queste attività:
+ Configura l'ambiente di progetto per eseguire questi TypeScript esempi di Node e installa i moduli richiesti AWS SDK per JavaScript e di terze parti. Segui le istruzioni su [ GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/ses/README.md).
+ Creazione di un file di configurazione condiviso con le credenziali utente. Per ulteriori informazioni sulla fornitura di un file di credenziali condiviso, consulta File di [configurazione e credenziali condivisi](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) nella Guida di riferimento *agli strumenti AWS SDKs e agli strumenti*.

**Importante**  
Questi esempi mostrano come import/export client gli oggetti e i comandi del servizio utilizzando ECMAScript6 (). ES6  
Ciò richiede la versione 13.x o successiva di Node.js. Per scaricare e installare la versione più recente di Node.js, consulta [Node.js downloads](https://nodejs.org/en/download). .
Se preferisci usare la sintassi CommonJS, vedi. [JavaScript ES6Sintassi /CommonJS](sdk-example-javascript-syntax.md)

## Elencare le tue identità
<a name="ses-examples-listing-identities"></a>

In questo esempio, utilizza un modulo Node.js per elencare gli indirizzi e-mail e i domini da utilizzare con Amazon SES.

Crea una `libs` directory e crea un modulo Node.js con il nome `sesClient.js` del file. Copia e incolla il codice seguente, che crea l'oggetto client Amazon SES. *REGION*Sostituiscilo con la tua AWS regione.

```
import { SESClient } from "@aws-sdk/client-ses";
// Set the AWS Region.
const REGION = "us-east-1";
// Credentials are automatically resolved using the AWS SDK credential provider chain.
// For more information, see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
// Create SES service object.
const sesClient = new SESClient({ region: REGION });
export { sesClient };
```

Questo codice di esempio può essere trovato [qui GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/libs/sesClient.js).

Crea un modulo Node.js con il nome del file `ses_listidentities.js`. Configura l'SDK come mostrato in precedenza, inclusa l'installazione dei client e dei pacchetti richiesti.

Crea un oggetto per trasferire `IdentityType` e altri parametri per il metodo `ListIdentitiesCommand` della classe client `SES`. Per chiamare il `ListIdentitiesCommand` metodo, richiama un oggetto di servizio Amazon SES, passando l'oggetto parameters. 

 Il `data` valore restituito contiene una matrice di identità di dominio come specificato dal `IdentityType` parametro.

**Nota**  
Sostituisci *IdentityType* con il tipo di identità, che può essere "EmailAddress" o «Dominio».

```
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;
  }
};
```

Per eseguire l'esempio, immettere quanto segue al prompt dei comandi.

```
node ses_listidentities.js 
```

Questo codice di esempio può essere trovato [qui su GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/ses_listidentities.js).

## Verifica di un'identità indirizzo e-mail
<a name="ses-examples-verifying-email"></a>

In questo esempio, utilizza un modulo Node.js per verificare i mittenti di posta elettronica da utilizzare con Amazon SES.

Crea una `libs` directory e crea un modulo Node.js con il nome `sesClient.js` del file. Copia e incolla il codice seguente, che crea l'oggetto client Amazon SES. *REGION*Sostituiscilo con la tua AWS regione.

```
import { SESClient } from "@aws-sdk/client-ses";
// Set the AWS Region.
const REGION = "us-east-1";
// Credentials are automatically resolved using the AWS SDK credential provider chain.
// For more information, see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
// Create SES service object.
const sesClient = new SESClient({ region: REGION });
export { sesClient };
```

Questo codice di esempio può essere trovato [qui GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/libs/sesClient.js).

Crea un modulo Node.js con il nome del file `ses_verifyemailidentity.js`. Configura l'SDK come mostrato in precedenza, incluso il download dei client e dei pacchetti richiesti. 

Crea un oggetto per trasferire il parametro `EmailAddress` per il metodo `VerifyEmailIdentityCommand` della classe client `SES`. Per chiamare il `VerifyEmailIdentityCommand` metodo, richiama un oggetto del servizio client Amazon SES, passando i parametri. 

**Nota**  
Sostituiscilo *EMAIL\$1ADDRESS* con l'indirizzo e-mail, ad esempio name@example.com.

```
// 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;
  }
};
```

Per eseguire l'esempio, immettere quanto segue al prompt dei comandi. Il dominio viene aggiunto ad Amazon SES per essere verificato.

```
node ses_verifyemailidentity.js 
```

Questo codice di esempio può essere trovato [qui su GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/ses_verifyemailidentity.js).

## Verifica dell'identità di un dominio
<a name="ses-examples-verifying-domains"></a>

In questo esempio, utilizza un modulo Node.js per verificare i domini e-mail da utilizzare con Amazon SES.

Crea una `libs` directory e crea un modulo Node.js con il nome `sesClient.js` del file. Copia e incolla il codice seguente, che crea l'oggetto client Amazon SES. *REGION*Sostituiscilo con la tua AWS regione.

```
import { SESClient } from "@aws-sdk/client-ses";
// Set the AWS Region.
const REGION = "us-east-1";
// Credentials are automatically resolved using the AWS SDK credential provider chain.
// For more information, see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
// Create SES service object.
const sesClient = new SESClient({ region: REGION });
export { sesClient };
```

Questo codice di esempio può essere trovato [qui GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/libs/sesClient.js).

Crea un modulo Node.js con il nome del file `ses_verifydomainidentity.js`. Configura l'SDK come mostrato in precedenza, inclusa l'installazione dei client e dei pacchetti richiesti.

Crea un oggetto per trasferire il parametro `Domain` per il metodo `VerifyDomainIdentityCommand` della classe client `SES`. Per chiamare il `VerifyDomainIdentityCommand` metodo, richiama un oggetto del servizio client Amazon SES, passando l'oggetto parameters. 

**Nota**  
Questo esempio importa e utilizza i client del pacchetto AWS Service V3 richiesti, i comandi V3 e utilizza il `send` metodo secondo uno schema. async/await È possibile creare questo esempio utilizzando i comandi V2 invece apportando alcune modifiche minori. Per informazioni dettagliate, vedi [Utilizzo dei comandi v3](migrating.md#using_v3_commands).

**Nota**  
Sostituisci *DOMAIN\$1NAME* con il nome di dominio.

```
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;
  }
};
```

Per eseguire l'esempio, immettere quanto segue al prompt dei comandi. Il dominio viene aggiunto ad Amazon SES per essere verificato.

```
node ses_verifydomainidentity.js  
```

Questo codice di esempio può essere trovato [qui su GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/ses_verifydomainidentity.js).

## Eliminazione delle identità
<a name="ses-examples-deleting-identities"></a>

In questo esempio, utilizza un modulo Node.js per eliminare gli indirizzi e-mail o i domini utilizzati con Amazon SES.

Crea una `libs` directory e crea un modulo Node.js con il nome `sesClient.js` del file. Copia e incolla il codice seguente, che crea l'oggetto client Amazon SES. *REGION*Sostituiscilo con la tua AWS regione.

```
import { SESClient } from "@aws-sdk/client-ses";
// Set the AWS Region.
const REGION = "us-east-1";
// Credentials are automatically resolved using the AWS SDK credential provider chain.
// For more information, see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
// Create SES service object.
const sesClient = new SESClient({ region: REGION });
export { sesClient };
```

Questo codice di esempio può essere trovato [qui GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/libs/sesClient.js).

Crea un modulo Node.js con il nome del file `ses_deleteidentity.js`. Configura l'SDK come mostrato in precedenza, inclusa l'installazione dei client e dei pacchetti richiesti.

Crea un oggetto per trasferire il parametro `Identity` per il metodo `DeleteIdentityCommand` della classe client `SES`. Per chiamare il `DeleteIdentityCommand` metodo, crea un oggetto del servizio client Amazon SES `request` per richiamare un oggetto del servizio client Amazon SES, passando i parametri. 

**Nota**  
Questo esempio importa e utilizza i client del pacchetto AWS Service V3 richiesti, i comandi V3 e utilizza il `send` metodo secondo uno schema. async/await È possibile creare questo esempio utilizzando i comandi V2 invece apportando alcune modifiche minori. Per informazioni dettagliate, vedi [Utilizzo dei comandi v3](migrating.md#using_v3_commands).

**Nota**  
Sostituisci *IDENTITY\$1EMAIL* con l'e-mail dell'identità da eliminare.

```
import { DeleteIdentityCommand } from "@aws-sdk/client-ses";
import { sesClient } from "./libs/sesClient.js";

const IDENTITY_EMAIL = "fake@example.com";

const createDeleteIdentityCommand = (identityName) => {
  return new DeleteIdentityCommand({
    Identity: identityName,
  });
};

const run = async () => {
  const deleteIdentityCommand = createDeleteIdentityCommand(IDENTITY_EMAIL);

  try {
    return await sesClient.send(deleteIdentityCommand);
  } catch (err) {
    console.log("Failed to delete identity.", err);
    return err;
  }
};
```

Per eseguire l'esempio, immettere quanto segue al prompt dei comandi.

```
node ses_deleteidentity.js 
```

Questo codice di esempio può essere trovato [qui su GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/ses/src/ses_deleteidentity.js).