Documentation

AmazonSesClient
in package

Amazon SES email client wrapper class.

Provides fluent interface for sending emails via AWS Simple Email Service with support for XML-based templates, CC/BCC recipients, and configuration sets.

use \X\Util\AmazonSesClient;

$ses  = new AmazonSesClient([
  'region' => $_ENV['AMS_SES_REGION'],
  'credentials' => [
    'key' => $_ENV['AMS_SES_ACCESS_KEY'],
    'secret' => $_ENV['AMS_SES_SECRET_KEY']
  ],
  'configuration' => $_ENV['AMS_SES_CONFIGURATION'],
]);
$ses
  ->from('from@example.com')
  ->to('to@example.com')
  ->messageFromXml('email/sample', ['name' => 'Alex'])
  ->send();

Email body and subject: application/views/email/sample.xml.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mail>
<subject>Test email.</subject>
<message>
Hi {{ name }}.
</message>
</mail>

Table of Contents

Properties

$bcc  : string
BCC email address.
$cc  : string
CC email address.
$charset  : string
Character code of the email. Default is "UTF-8".
$from  : string
Sender's email address.
$fromName  : string
Sender name.
$message  : string
Body.
$options  : array<string|int, mixed>
SES client options.
$subject  : string
Subject.
$to  : string
Destination email address.

Methods

__construct()  : mixed
Initialize AmazonSesClient.
bcc()  : AmazonSesClient
Set BCC email address.
cc()  : AmazonSesClient
Set CC email address.
charset()  : AmazonSesClient
Set charset.
from()  : AmazonSesClient
Set the sender.
message()  : AmazonSesClient
Set Body.
messageFromXml()  : AmazonSesClient
Set the mail body based on XML.
send()  : array{MessageId: string}
Send.
subject()  : AmazonSesClient
Set Subject.
to()  : AmazonSesClient
Set Destination email address.
client()  : SesClient
Get SES client instance.
reset()  : void
Reset options.

Properties

$charset

Character code of the email. Default is "UTF-8".

private string $charset = 'UTF-8'

$options

SES client options.

private array<string|int, mixed> $options = null
  • credentials: array with 'key' and 'secret' for AWS credentials
  • configuration: string|null configuration set name
  • region: string AWS region (e.g., 'ap-northeast-1')
  • version: string API version (default: 'latest')

Methods

__construct()

Initialize AmazonSesClient.

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

messageFromXml()

Set the mail body based on XML.

public messageFromXml(string $xmlPath[, array<string|int, mixed> $params = [] ]) : AmazonSesClient
Parameters
$xmlPath : string

Path of the XML file. Relative path from application/views/.

$params : array<string|int, mixed> = []

(optional) Embedded variables for subject and body text.

Return values
AmazonSesClient

send()

Send.

public send() : array{MessageId: string}
Return values
array{MessageId: string}

Result of email transmission.

client()

Get SES client instance.

private client() : SesClient
Return values
SesClient

SES client instance.


        
On this page

Search results