AWS SDK for PHP
Developer Guide

Monitoring Your Sending Activity Using the Amazon SES API and the AWS SDK for PHP Version 3

Amazon Simple Email Service (Amazon SES) provides methods for monitoring your sending activity. We recommend that you implement these methods so that you can keep track of important measures, such as your account's bounce, complaint, and reject rates. Excessively high bounce and complaint rates can jeopardize your ability to send emails using Amazon SES.

The following examples show how to:

All the example code for the AWS SDK for PHP Version 3 is available here on GitHub.

Credentials

Before running the example code, configure your AWS credentials, as described in Credentials for the AWS SDK for PHP Version 3. Then import the AWS SDK for PHP, as described in Basic Usage Patterns of the AWS SDK for PHP Version 3.

For more information about using Amazon SES, see the Amazon SES Developer Guide.

Check Your Sending Quota

You are limited to sending only a certain amount of messages in a single 24-hour period. To check how many messages you are still allowed to send, use the GetSendQuota operation. For more information, see Managing Your Amazon SES Sending Limits.

Imports

require 'vendor/autoload.php'; use Aws\Ses\SesClient; use Aws\Exception\AwsException;

Sample Code

$SesClient = new SesClient([ 'profile' => 'default', 'version' => '2010-12-01', 'region' => 'us-east-1' ]); try { $result = $SesClient->getSendQuota([ ]); $send_limit = $result["Max24HourSend"]; $sent = $result["SentLast24Hours"]; $available = $send_limit - $sent; print("<p>You can send " . $available . " more messages in the next 24 hours.</p>"); var_dump($result); } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; }

Monitor Your Sending Activity

To retrieve metrics for messages you've sent in the past two weeks, use the GetSendStatistics operation. This example returns the number of delivery attempts, bounces, complaints, and rejected messages in 15-minute increments.

Imports

require 'vendor/autoload.php'; use Aws\Ses\SesClient; use Aws\Exception\AwsException;

Sample Code

$SesClient = new SesClient([ 'profile' => 'default', 'version' => '2010-12-01', 'region' => 'us-east-1' ]); try { $result = $SesClient->getSendStatistics([ ]); var_dump($result); } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; }