Ses client

This page contains examples with the Ses client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.

The Ses package could be installed with Composer.

composer require async-aws/ses

A new client object may be instantiated by:

use AsyncAws\Ses\SesClient; $ses = new SesClient();

The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:

use AsyncAws\Ses\SesClient; $ses = new SesClient([ 'accessKeyId' => 'my_access_key', 'accessKeySecret' => 'my_access_secret', 'region' => 'eu-central-1', ]);

For all available options, see the configuration reference.


Send a message

use AsyncAws\Ses\Input\SendEmailRequest; use AsyncAws\Ses\SesClient; use AsyncAws\Ses\ValueObject\Body; use AsyncAws\Ses\ValueObject\Content; use AsyncAws\Ses\ValueObject\Destination; use AsyncAws\Ses\ValueObject\EmailContent; use AsyncAws\Ses\ValueObject\Message; $ses = new SesClient(); $result = $ses->sendEmail(new SendEmailRequest([ 'FromEmailAddress' => '', 'Content' => new EmailContent([ 'Simple' => new Message([ 'Subject' => new Content(['Data' => 'New Invoice']), 'Body' => new Body([ 'Text' => new Content(['Data' => 'A new invoice is available']), ]), ]), ]), 'Destination' => new Destination([ 'ToAddresses' => [''] ]), ])); echo $result->getMessageId();

The source code to this page is found on GitHub.