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.