Sample code for 30+ languages & platforms
PowerBuilder

Amazon SES: Check sender verification status

See more Amazon SES Examples

Check the email identity created in Request sender verification. This read-only SES Query API operation uses ses:GetIdentityVerificationAttributes. It can look up several email addresses or domains in one signed request. Pending means SES is waiting for confirmation. Success means SES verified the identity. An address can also inherit verification from its domain.

GetIdentityVerificationAttributes

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
string ls_Region
oleobject loo_Host
oleobject loo_Signer
oleobject loo_Connection
oleobject loo_Rest
string ls_SessionToken
string ls_ResponseText
oleobject loo_Result
string ls_Status

li_Success = 0

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

li_Success = 0

//  Use the same AWS Region for the identity, endpoint, and Signature Version 4.
ls_Region = "us-west-2"
loo_Host = create oleobject
li_rc = loo_Host.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
    destroy loo_Host
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Host.Append("email.")
loo_Host.Append(ls_Region)
loo_Host.Append(".amazonaws.com")

loo_Signer = create oleobject
li_rc = loo_Signer.ConnectToNewObject("Chilkat.AuthAws")

//  Supply the credentials from your application's credential provider.
loo_Signer.AccessKey = "AWS_ACCESS_KEY_ID"
loo_Signer.SecretKey = "AWS_SECRET_ACCESS_KEY"
loo_Signer.Region = ls_Region
loo_Signer.ServiceName = "ses"

loo_Connection = create oleobject
li_rc = loo_Connection.ConnectToNewObject("Chilkat.Socket")

loo_Connection.RequireSslCertVerify = 1
li_Success = loo_Connection.Connect(loo_Host.GetAsString(),443,1,10000)
if li_Success <> 1 then
    Write-Debug loo_Connection.LastErrorText
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    return
end if

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")

li_Success = loo_Rest.UseConnection(loo_Connection,0)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    destroy loo_Rest
    return
end if

li_Success = loo_Rest.SetAuthAws(loo_Signer)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    destroy loo_Rest
    return
end if

//  For temporary AWS credentials, supply the session token from the same provider.
ls_SessionToken = ""
if ls_SessionToken <> "" then
    loo_Rest.AddQueryParam("X-Amz-Security-Token",ls_SessionToken)
end if

//  This read-only SES Query action accepts up to 100 addresses or domains.
//  Pass the original mailbox name. Chilkat encodes the plus sign when signing the query.
loo_Rest.AddQueryParam("Action","GetIdentityVerificationAttributes")
loo_Rest.AddQueryParam("Version","2010-12-01")
loo_Rest.AddQueryParam("Identities.member.1","sender+reports@example.com")
ls_ResponseText = loo_Rest.FullRequestNoBody("GET","/")
if loo_Rest.LastMethodSuccess <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    destroy loo_Rest
    return
end if

if loo_Rest.ResponseStatusCode <> 200 then
    Write-Debug "SES returned HTTP " + string(loo_Rest.ResponseStatusCode) + " " + ls_ResponseText
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    destroy loo_Rest
    return
end if

loo_Result = create oleobject
li_rc = loo_Result.ConnectToNewObject("Chilkat.Xml")

li_Success = loo_Result.LoadXml(ls_ResponseText)
if li_Success <> 1 then
    Write-Debug loo_Result.LastErrorText
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    destroy loo_Rest
    destroy loo_Result
    return
end if

//  A map entry contains the identity as key and its verification attributes as value.
if loo_Result.NumChildrenAt("GetIdentityVerificationAttributesResult|VerificationAttributes") < 1 then
    Write-Debug "No verification entry returned for this address in this Region."
    destroy loo_Host
    destroy loo_Signer
    destroy loo_Connection
    destroy loo_Rest
    destroy loo_Result
    return
end if

ls_Status = loo_Result.GetChildContent("GetIdentityVerificationAttributesResult|VerificationAttributes|entry|value|VerificationStatus")
Write-Debug "Verification status: " + ls_Status
if ls_Status = "Pending" then
    Write-Debug "Open the AWS verification email and follow its link."
end if



destroy loo_Host
destroy loo_Signer
destroy loo_Connection
destroy loo_Rest
destroy loo_Result