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à.
Salve Amazon SES API v2
Il seguente esempio di codice mostra come iniziare a utilizzare l'API Amazon SES v2.
- Python
-
- SDK per Python (Boto3)
-
def hello_sesv2(sesv2_client):
"""
Use the AWS SDK for Python (Boto3) to create an Amazon SESv2 client and
list the email identities in your account. This example uses the default
settings specified in your shared credentials and config files.
:param sesv2_client: A Boto3 SESv2 client object.
"""
print("Hello, Amazon SESv2. Let's list up to 5 email identities:\n")
try:
response = sesv2_client.list_email_identities(PageSize=5)
identities = response["EmailIdentities"]
if not identities:
print(
"No email identities found. "
"Use CreateEmailIdentity to add one."
)
else:
for identity in identities:
print(
f" Identity: {identity['IdentityName']}"
f" Type: {identity['IdentityType']}"
f" Status: {identity['VerificationStatus']}"
f" Sending: {'Enabled' if identity['SendingEnabled'] else 'Disabled'}"
)
print(f"\nShowing {len(identities)} email identity(ies).")
except ClientError as err:
logger.error(
"Couldn't list email identities. Here's why: %s: %s",
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raise
Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, consulta. Utilizzo di Amazon SES con un AWS SDK Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell’SDK.