View a markdown version of this page

你好 Amazon SES API v2 - Amazon Simple Email Service

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

你好 Amazon SES API v2

以下代码示例展示了如何开始使用 Amazon SES API v2。

Python
适用于 Python 的 SDK(Boto3)
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

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
  • 有关 API 的详细信息,请参阅适用ListEmailIdentitiesPython 的AWS SDK (Boto3) API 参考

有关 S AWS DK 开发者指南和代码示例的完整列表,请参阅将 Amazon SES 与 AWS 软件开发工具包配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。