Search code examples
phpamazon-web-servicesamazon-ses

How to retrieve response from Amazon SES?


I have the code to verify email address in Amazon ses

<?php
$sesClient = SesClient::factory(array(
            'key'    => 'secret key',
            'secret' => 'secret',
            'profile' => 'user_name',
            'region'  => 'us-east-1'
        ));
$result = $sesClient->verifyEmailAddress(array('EmailAddress'=> $email));
?>

My output for $result is like this:

object(Guzzle\Service\Resource\Model) {
    [protected] structure => null
    [protected] data => array()
}

I actually got verified email in the email id I have specified. My question is, how to check whether the function worked correctly using the response I have received? In earlier Amazon web services, they used $result->is('Ok') to verify the result. what function should I use now to check the result for success and failure of that function?

I've checked with the amazon link and still can't find the function for successful response


Solution

  • Looking at tests of aws-sdk-php found this:

    https://github.com/aws/aws-sdk-php/blob/master/tests/Aws/Tests/Ses/Integration/IntegrationTest.php#L86

    Maybe you can try:

    $sesClient->verifyEmailAddress(array('EmailAddress'=> $email));
    $sesClient->waitUntilIdentityExists(array('Identities' => array($email)));
    $result = $sesClient->getIdentityVerificationAttributes(array('Identities' => array($email)));
    if ('Success' === $result->getPath("VerificationAttributes/{$email}/VerificationStatus"))