I am trying to setup an email queue via Amazon SES to make sure I can send multiple emails at the sametime (limited to 14 emails per second).
I am constantly getting a sign in error
The email was not sent. Error message: Error executing "SendEmail" on "https://email.us-west-2.amazonaws.com"; AWS HTTP error: Client error:
POST https://email.us-west-2.amazonaws.com
resulted in a403 Forbidden
response: Sender SignatureDo (truncated...) SignatureDoesNotMatch (client): The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. The Canonical String for this request should have been 'POST / aws-sdk-invocation-id:4d2929e4b7ca73cfe9370d1b848d398d aws-sdk-retry:0/0 host:email.us-west-2.amazonaws.com x-amz-date:20170311T031541Z aws-sdk-invocation-id;aws-sdk-retry;host;x-amz-date 486b4c1288d7c5717c3a0bccdaf10f67eb02ca5da8fbfed75298e98e8f785048' The String-to-Sign should have been 'AWS4-HMAC-SHA256 20170311T031541Z 20170311/us-west-2/email/aws4_request ce02f756d98ab45ab63754fd6ec64a6621c36ed802316ff22c2c877535925735' - Sender SignatureDoesNotMatch The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. The Canonical String for this request should have been 'POST / aws-sdk-invocation-id:4d2929e4b7ca73cfe9370d1b848d398d aws-sdk-retry:0/0 host:email.us-west-2.amazonaws.com x-amz-date:20170311T031541Z aws-sdk-invocation-id;aws-sdk-retry;host;x-amz-date 486b4c1288d7c5717c3a0bccdaf10f67eb02ca5da8fbfed75298e98e8f785048' The String-to-Sign should have been 'AWS4-HMAC-SHA256 20170311T031541Z 20170311/us-west-2/email/aws4_request ce02f756d98ab45ab63754fd6ec64a6621c36ed802316ff22c2c877535925735' 028b5fb9-0609-11e7-9549-6d5ec2e3cc18
and I tried other solutions on stackoverflow without success.
PHP code:
ini_set('display_errors', 'On');
error_reporting(E_ALL);
// aws.amazon.com/code/
// docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-sdk-php.html
// Replace path_to_sdk_inclusion with the path to the SDK as described in
// docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/basic-usage.html
define('REQUIRED_FILE','aws/aws-autoloader.php');
// Replace [email protected] with your "From" address.
// This address must be verified with Amazon SES.
define('SENDER', '[email protected]');
// Replace [email protected] with a "To" address. If your account
// is still in the sandbox, this address must be verified.
define('RECIPIENT', '[email protected]');
// Replace us-west-2 with the AWS region you're using for Amazon SES.
define('REGION','us-west-2');
define('SUBJECT','Amazon SES test (AWS SDK for PHP)');
define('BODY','This email was sent with Amazon SES using the AWS SDK for PHP.');
require REQUIRED_FILE;
use Aws\Ses\SesClient;
$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION,
'credentials' => array(
'key' => 'xxxx',
'secret' => 'xxxx',
)
));
$request = array();
$request['Source'] = SENDER;
$request['Destination']['ToAddresses'] = array(RECIPIENT);
$request['Message']['Subject']['Data'] = SUBJECT;
$request['Message']['Body']['Text']['Data'] = BODY;
try {
$result = $client->sendEmail($request);
$messageId = $result->get('MessageId');
echo("Email sent! Message ID: $messageId"."\n");
} catch (Exception $e) {
echo("The email was not sent. Error message: ");
echo($e->getMessage()."\n");
}
You will make my day if you can help.