Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkStringBuilderW.h>
#include <C_CkAuthAwsW.h>
#include <C_CkSocketW.h>
#include <C_CkRestW.h>
#include <C_CkXmlW.h>
void ChilkatSample(void)
{
BOOL success;
const wchar_t *region;
HCkStringBuilderW host;
HCkAuthAwsW signer;
HCkSocketW connection;
HCkRestW rest;
const wchar_t *sessionToken;
const wchar_t *responseText;
HCkXmlW result;
const wchar_t *status;
success = FALSE;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
success = FALSE;
// Use the same AWS Region for the identity, endpoint, and Signature Version 4.
region = L"us-west-2";
host = CkStringBuilderW_Create();
CkStringBuilderW_Append(host,L"email.");
CkStringBuilderW_Append(host,region);
CkStringBuilderW_Append(host,L".amazonaws.com");
signer = CkAuthAwsW_Create();
// Supply the credentials from your application's credential provider.
CkAuthAwsW_putAccessKey(signer,L"AWS_ACCESS_KEY_ID");
CkAuthAwsW_putSecretKey(signer,L"AWS_SECRET_ACCESS_KEY");
CkAuthAwsW_putRegion(signer,region);
CkAuthAwsW_putServiceName(signer,L"ses");
connection = CkSocketW_Create();
CkSocketW_putRequireSslCertVerify(connection,TRUE);
success = CkSocketW_Connect(connection,CkStringBuilderW_getAsString(host),443,TRUE,10000);
if (success != TRUE) {
wprintf(L"%s\n",CkSocketW_lastErrorText(connection));
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
return;
}
rest = CkRestW_Create();
success = CkRestW_UseConnection(rest,connection,FALSE);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
return;
}
success = CkRestW_SetAuthAws(rest,signer);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
return;
}
// For temporary AWS credentials, supply the session token from the same provider.
sessionToken = L"";
if (sessionToken != L"") {
CkRestW_AddQueryParam(rest,L"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.
CkRestW_AddQueryParam(rest,L"Action",L"GetIdentityVerificationAttributes");
CkRestW_AddQueryParam(rest,L"Version",L"2010-12-01");
CkRestW_AddQueryParam(rest,L"Identities.member.1",L"sender+reports@example.com");
responseText = CkRestW_fullRequestNoBody(rest,L"GET",L"/");
if (CkRestW_getLastMethodSuccess(rest) != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
return;
}
if (CkRestW_getResponseStatusCode(rest) != 200) {
wprintf(L"SES returned HTTP %d %s\n",CkRestW_getResponseStatusCode(rest),responseText);
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
return;
}
result = CkXmlW_Create();
success = CkXmlW_LoadXml(result,responseText);
if (success != TRUE) {
wprintf(L"%s\n",CkXmlW_lastErrorText(result));
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
CkXmlW_Dispose(result);
return;
}
// A map entry contains the identity as key and its verification attributes as value.
if (CkXmlW_NumChildrenAt(result,L"GetIdentityVerificationAttributesResult|VerificationAttributes") < 1) {
wprintf(L"No verification entry returned for this address in this Region.\n");
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
CkXmlW_Dispose(result);
return;
}
status = CkXmlW_getChildContent(result,L"GetIdentityVerificationAttributesResult|VerificationAttributes|entry|value|VerificationStatus");
wprintf(L"Verification status: %s\n",status);
if (status == L"Pending") {
wprintf(L"Open the AWS verification email and follow its link.\n");
}
CkStringBuilderW_Dispose(host);
CkAuthAwsW_Dispose(signer);
CkSocketW_Dispose(connection);
CkRestW_Dispose(rest);
CkXmlW_Dispose(result);
}