搭DeleteIdentity配 AWS 開發套件或 CLI 使用 - Amazon Simple Email Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DeleteIdentity配 AWS 開發套件或 CLI 使用

下列程式碼範例會示範如何使用DeleteIdentity

動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:

.NET
AWS SDK for .NET
注意

還有更多關於 GitHub。尋找完整範例,並了解如何在AWS 設定和執行程式碼範例儲存庫

/// <summary> /// Delete an email identity. /// </summary> /// <param name="identityEmail">The identity email to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteIdentityAsync(string identityEmail) { var success = false; try { var response = await _amazonSimpleEmailService.DeleteIdentityAsync( new DeleteIdentityRequest { Identity = identityEmail }); success = response.HttpStatusCode == HttpStatusCode.OK; } catch (Exception ex) { Console.WriteLine("DeleteIdentityAsync failed with exception: " + ex.Message); } return success; }
  • 如需 API 詳細資訊,請參閱 AWS SDK for .NET API 參考DeleteIdentity中的。

C++
適用於 C++ 的 SDK
注意

還有更多關於 GitHub。尋找完整範例,並了解如何在AWS 設定和執行程式碼範例儲存庫

//! Delete the specified identity (an email address or a domain). /*! \param identity: The identity to delete. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteIdentity(const Aws::String &identity, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteIdentityRequest deleteIdentityRequest; deleteIdentityRequest.SetIdentity(identity); Aws::SES::Model::DeleteIdentityOutcome outcome = sesClient.DeleteIdentity( deleteIdentityRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted identity." << std::endl; } else { std::cerr << "Error deleting identity. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • 如需 API 詳細資訊,請參閱 AWS SDK for C++ API 參考DeleteIdentity中的。

CLI
AWS CLI

刪除身分

下列範例使用 delete-identity 命令從透過 Amazon SES 驗證的身分清單中刪除身分:

aws ses delete-identity --identity user@example.com

如需驗證的身分詳細資訊,請參閱《Amazon Simple Email Service 開發人員指南》中的「在 Amazon SES 中驗證電子郵件地址和網域」。

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DeleteIdentity中的。

JavaScript
適用於 JavaScript (v3) 的開發套件
注意

還有更多關於 GitHub。尋找完整範例,並了解如何在AWS 設定和執行程式碼範例儲存庫

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; } };
  • 如需 API 詳細資訊,請參閱 AWS SDK for JavaScript API 參考DeleteIdentity中的。

Python
適用於 Python (Boto3) 的 SDK
注意

還有更多關於 GitHub。尋找完整範例,並了解如何在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 delete_identity(self, identity): """ Deletes an identity. :param identity: The identity to remove. """ try: self.ses_client.delete_identity(Identity=identity) logger.info("Deleted identity %s.", identity) except ClientError: logger.exception("Couldn't delete identity %s.", identity) raise
  • 如需 API 的詳細資訊,請參閱AWS 開發套件DeleteIdentity中的 Python (博托 3) API 參考。

如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱搭配 AWS 開發套件使用 Amazon SES。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。