文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
GetIdentityVerificationAttributes
搭配 a AWS SDK 或 CLI 使用
下列程式碼範例示範如何使用 GetIdentityVerificationAttributes
。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 /// <summary> /// Get identity verification status for an email. /// </summary> /// <returns>The verification status of the email.</returns> public async Task<VerificationStatus> GetIdentityStatusAsync(string email) { var result = VerificationStatus.TemporaryFailure; try { var response = await _amazonSimpleEmailService.GetIdentityVerificationAttributesAsync( new GetIdentityVerificationAttributesRequest { Identities = new List<string> { email } }); if (response.VerificationAttributes.ContainsKey(email)) result = response.VerificationAttributes[email].VerificationStatus; } catch (Exception ex) { Console.WriteLine("GetIdentityStatusAsync failed with exception: " + ex.Message); } return result; }
-
如需 API 詳細資訊,請參閱 GetIdentityVerificationAttributes AWS SDK for .NET 參考中的 API。
-
- CLI
-
- AWS CLI
-
取得身分清單的 Amazon SES 驗證狀態
下列範例使用
get-identity-verification-attributes
命令來擷取身分清單的 Amazon SES 驗證狀態:aws ses get-identity-verification-attributes --identities
"user1@example.com"
"user2@example.com"
輸出:
{ "VerificationAttributes": { "user1@example.com": { "VerificationStatus": "Success" }, "user2@example.com": { "VerificationStatus": "Pending" } } }
如果您使用從未提交進行驗證的身分來呼叫此命令,則該身分不會出現在輸出中。
如需已驗證身分的詳細資訊,請參閱 Amazon Simple Email Service 開發人員指南中的在 Amazon SES 中驗證電子郵件地址和網域。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 GetIdentityVerificationAttributes
。
-
- Python
-
- SDK for Python (Boto3)
-
注意
還有更多 on 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 get_identity_status(self, identity): """ Gets the status of an identity. This can be used to discover whether an identity has been successfully verified. :param identity: The identity to query. :return: The status of the identity. """ try: response = self.ses_client.get_identity_verification_attributes( Identities=[identity] ) status = response["VerificationAttributes"].get( identity, {"VerificationStatus": "NotFound"} )["VerificationStatus"] logger.info("Got status of %s for %s.", status, identity) except ClientError: logger.exception("Couldn't get status for %s.", identity) raise else: return status
-
如需 API 詳細資訊,請參閱 GetIdentityVerificationAttributes AWS SDK for Python (Boto3) Word 參考中的 API。
-
- Ruby
-
- Ruby 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 require 'aws-sdk-ses' # v2: require 'aws-sdk' # Create client in us-west-2 region # Replace us-west-2 with the AWS Region you're using for Amazon SES. client = Aws::SES::Client.new(region: 'us-west-2') # Get up to 1000 identities ids = client.list_identities({ identity_type: 'EmailAddress' }) ids.identities.each do |email| attrs = client.get_identity_verification_attributes({ identities: [email] }) status = attrs.verification_attributes[email].verification_status # Display email addresses that have been verified puts email if status == 'Success' end
-
如需 API 詳細資訊,請參閱 GetIdentityVerificationAttributes AWS SDK for Ruby 參考中的 API。
-