0

I am trying to integrate the AWS PHP SDK with my application so that it can send emails using the AWS Simple Email Service. I have the following PHP code:

require_once 'Aws/aws-autoloader.php';

$client = Aws\Ses\SesClient::factory(array(
    'version'=> '2010-12-01',
    'region' => 'us-west-2',
    'credentials' => [
        'key'    => $access_key_id,
        'secret' => $access_key_secret,
    ],
));

try {
    $result = $client->sendRawEmail([
        'Source' => $from_email,
        'Destination' => [
            'ToAddresses' => [
                $to_email,
            ],
        ],
        'RawMessage' => [
            'Data' => $raw_message
        ],
    ]);
    $messageId = $result->get('MessageId');

} catch (Aws\Ses\Exception\SesException $error) {
    echo("The email was not sent. Error message: ".$error->getAwsErrorMessage()."\n");
}

The above code returns an empty error message, The email wasn't delivered however.

The email was not sent. Error message: 

I have completed the verification steps in AWS to verify the email ownership and my account is out of the sandbox mode. When I use the "Send a Test Email" function on the AWS console to send a test email, the email was sent successfully.

K Hsueh
  • 610
  • 1
  • 10
  • 19
  • Echo `$error->getRequest()` and `$error->getResponse()`. This should help you figure out the error. Include all the information necessary to help you such as the `$raw_message` in your question. – John Hanley Oct 03 '18 at 05:51
  • I figured out that the {"status":"Success"} bit comes from my other code.... The getAwsErrorMessage() is actually returning null. I tried the $error->getResponse() as suggested but it is also giving a null response. The request object seems to look fine. – K Hsueh Oct 03 '18 at 06:11
  • Mind sharing an example of a $raw_message that triggers the error? – Jonathan Oct 03 '18 at 22:11

0 Answers0