Sample code for 30+ languages & platforms
Tcl

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 Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

set success 0

#  Use the same AWS Region for the identity, endpoint, and Signature Version 4.
set region "us-west-2"
set host [new_CkStringBuilder]

CkStringBuilder_Append $host "email."
CkStringBuilder_Append $host $region
CkStringBuilder_Append $host ".amazonaws.com"

set signer [new_CkAuthAws]

#  Supply the credentials from your application's credential provider.
CkAuthAws_put_AccessKey $signer "AWS_ACCESS_KEY_ID"
CkAuthAws_put_SecretKey $signer "AWS_SECRET_ACCESS_KEY"
CkAuthAws_put_Region $signer $region
CkAuthAws_put_ServiceName $signer "ses"

set connection [new_CkSocket]

CkSocket_put_RequireSslCertVerify $connection 1
set success [CkSocket_Connect $connection [CkStringBuilder_getAsString $host] 443 1 10000]
if {$success != 1} then {
    puts [CkSocket_lastErrorText $connection]
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    exit
}

set rest [new_CkRest]

set success [CkRest_UseConnection $rest $connection 0]
if {$success != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    delete_CkRest $rest
    exit
}

set success [CkRest_SetAuthAws $rest $signer]
if {$success != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    delete_CkRest $rest
    exit
}

#  For temporary AWS credentials, supply the session token from the same provider.
set sessionToken ""
if {$sessionToken != ""} then {
    CkRest_AddQueryParam $rest "X-Amz-Security-Token" $sessionToken
}

#  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.
CkRest_AddQueryParam $rest "Action" "GetIdentityVerificationAttributes"
CkRest_AddQueryParam $rest "Version" "2010-12-01"
CkRest_AddQueryParam $rest "Identities.member.1" "sender+reports@example.com"
set responseText [CkRest_fullRequestNoBody $rest "GET" "/"]
if {[CkRest_get_LastMethodSuccess $rest] != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    delete_CkRest $rest
    exit
}

if {[CkRest_get_ResponseStatusCode $rest] != 200} then {
    puts "SES returned HTTP [CkRest_get_ResponseStatusCode $rest] $responseText"
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    delete_CkRest $rest
    exit
}

set result [new_CkXml]

set success [CkXml_LoadXml $result $responseText]
if {$success != 1} then {
    puts [CkXml_lastErrorText $result]
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    delete_CkRest $rest
    delete_CkXml $result
    exit
}

#  A map entry contains the identity as key and its verification attributes as value.
if {[CkXml_NumChildrenAt $result "GetIdentityVerificationAttributesResult|VerificationAttributes"] < 1} then {
    puts "No verification entry returned for this address in this Region."
    delete_CkStringBuilder $host
    delete_CkAuthAws $signer
    delete_CkSocket $connection
    delete_CkRest $rest
    delete_CkXml $result
    exit
}

set status [CkXml_getChildContent $result "GetIdentityVerificationAttributesResult|VerificationAttributes|entry|value|VerificationStatus"]
puts "Verification status: $status"
if {$status == "Pending"} then {
    puts "Open the AWS verification email and follow its link."
}


delete_CkStringBuilder $host
delete_CkAuthAws $signer
delete_CkSocket $connection
delete_CkRest $rest
delete_CkXml $result