Reputation: 3073
I am trying to use the latest SDK for PHP (v. 1.5.0). I am trying to send an email with AmazonSES. I have successully sent emails with the python scripts, so I know that my crendentials and other settings are okay.
I have copied the sample code however, it does not work. When calling AmazonSES, I get an error saying:
Catchable fatal error: Argument 1 passed to AmazonSES::__construct() must
be an array, string given, called in sendemail.php on line 31 and
defined in sdk-1.5.0/services/ses.class.php on line 67
This is the code:
$AWS_KEY = "AKIEDIEDEIMIAXEOA";
$AWS_SECRET_KEY = "Te+EDEwjndjndededededededj";
require_once("../library/lib_aws/sdk-1.5.0/sdk.class.php");
$amazonSes = new AmazonSES($AWS_KEY, $AWS_SECRET_KEY);
$response = $amazonSes->send_email(
"[email protected]",
array("ToAddresses" => "[email protected]"),
array(
"Subject.Data" => "test",
"Body.Text.Data" => "body test",
)
);
if (!$response->isOK())
{
echo "error";
}
I cannot find how to set up the credentials correctly to send an email.
Upvotes: 3
Views: 2433
Reputation: 127
ToAddress's value must be an array, not a string. This should work:
require_once('amazonsdk/sdk.class.php');
$ses = new AmazonSES();
$response = $ses->send_email(
"[email protected]",
array("ToAddresses"=>array('[email protected]')),
array("Subject.Data"=>"Testing SES subject","Body.Text.Data"=>"Testing SES body.")
);
print_r($response);
Upvotes: -2
Reputation: 3873
Yeah, the config file format and the service constructors changed slightly in version 1.5. They mentioned this as a backwards-incompatible change in the release notes.
http://aws.amazon.com/releasenotes/PHP/3719565440874916
Upvotes: 2
Reputation: 4297
The constructor for AmazonSES takes an array with options. Check the source:
https://github.com/amazonwebservices/aws-sdk-for-php/blob/master/services/ses.class.php#L55
You'll want to write it like:
$amazonSes = new AmazonSES(array(
"key" => $AWS_KEY,
"secret" => $AWS_SECRET_KEY
));
Please click through to the source (or consult the docs) to make sure there aren't other options you need to set.
Upvotes: 8