I have a simple copy-paste code from AWS SES PHP SDK v3 to send bulk emails using sendTemplatedEmail function.
but it's throwing this error:
Type: ParseError
Message: syntax error, unexpected ',', expecting ';'
Filename: /home/sites/10a/9/9bdb792fe4/public_html/application/third_party/amazon_ses/vendor/aws/aws-sdk-php/src/data/email/2010-12-01/api-2.json.php
Line Number: 3
File: /home/sites/10a/9/9bdb792fe4/public_html/application/helpers/amazonses_helper.php
Line: 24
Function: __construct
This is the code and the error is at line number 24 which is the line where I am providing the credentials i.e., 'credentials' => [ 'key' => AMAZON_SES_KEY_ID, 'secret' => AMAZON_SES_SECRET_KEY ]
public static function send_bulk_mail($data)
{
$SesClient = new Aws\Ses\SesClient([
'profile' => 'default',
'version' => '2010-12-01',
'region' => 'eu-west-1',
'credentials' => [ 'key' => AMAZON_SES_KEY_ID, 'secret' => AMAZON_SES_SECRET_KEY ]
]);
$template_name = 'default';
$sender_email = 'support@example.com';
$recipient_emails = array();
foreach($data['recipients'] as $index => $person){
$recipient_emails[$index] = $person['email'];
}
try {
$result = $SesClient->sendTemplatedEmail([
'Destination' => [
'ToAddresses' => $recipient_emails,
],
'ReplyToAddresses' => [$sender_email],
'Source' => $sender_email,
'Template' => $template_name,
'TemplateData' => '{ }'
]);
var_dump($result);
} catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo "\n";
}
}