NewbieSSProgrammer NewbieSSProgrammer - 1 year ago 121
PHP Question

Amazon SES PHPMail or SDK

I've registered with Amazon SES service with email limit setup and out of the sandbox. I've tried many PHPMailer function and all return me as error : Connexion time out (110). Is it possible the send mail from PHPMailer?

I have seen on Amazon SES site this link.


// Replace path_to_sdk_inclusion with the path to the SDK as described in

// Replace with your "From" address.
// This address must be verified with Amazon SES.
define('SENDER', '');

// Replace with a "To" address. If your account
// is still in the sandbox, this address must be verified.
define('RECIPIENT', '');

// Replace us-west-2 with the AWS region you're using for Amazon SES.

define('SUBJECT','Amazon SES test (AWS SDK for PHP)');
define('BODY','This email was sent with Amazon SES using the AWS SDK for PHP.');


use Aws\Ses\SesClient;

$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION

$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: ");


I've copy all the codes, put my variable instead of showned in the demo script. Now I'm getting the error : You must use KEY ans SECRET_KEY to use this script... Where I cant put my KEY and SECRETKEY in the script? There is no explanation on how to do this.

Is there another way send email throught Amazon SES service?

Answer Source

So simple. I have to add key and secret in :

$client = SesClient::factory(array(
    'version'=> 'latest',     
    'region' => REGION,
     'credentials' => array(
        'key'    => 'XXXXXXXXXXXXXXXX',
        'secret' => 'XXXXXXXXXXXXXXXX',

and set XXXXXXXXXXXXXXXX full access to api in amazon security credentials

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download