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
$bcc
BCC email address.
private
string
$bcc
= null
$cc
CC email address.
private
string
$cc
= null
$charset
Character code of the email. Default is "UTF-8".
private
string
$charset
= 'UTF-8'
$from
Sender's email address.
private
string
$from
= null
$fromName
Sender name.
private
string
$fromName
= null
$message
Body.
private
string
$message
= null
$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')
$subject
Subject.
private
string
$subject
= null
$to
Destination email address.
private
string
$to
= null
Methods
__construct()
Initialize AmazonSesClient.
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
bcc()
Set BCC email address.
public
bcc(string $bcc) : AmazonSesClient
Parameters
- $bcc : string
-
BCC email address.
Return values
AmazonSesClientcc()
Set CC email address.
public
cc(string $cc) : AmazonSesClient
Parameters
- $cc : string
-
CC email address.
Return values
AmazonSesClientcharset()
Set charset.
public
charset(string $charset) : AmazonSesClient
Parameters
- $charset : string
-
Character code of the email.
Return values
AmazonSesClientfrom()
Set the sender.
public
from(string $from[, string $fromName = null ]) : AmazonSesClient
Parameters
- $from : string
-
Sender's email address.
- $fromName : string = null
-
Sender name.
Return values
AmazonSesClientmessage()
Set Body.
public
message(string $message) : AmazonSesClient
Parameters
- $message : string
Return values
AmazonSesClientmessageFromXml()
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
AmazonSesClientsend()
Send.
public
send() : array{MessageId: string}
Return values
array{MessageId: string} —Result of email transmission.
subject()
Set Subject.
public
subject(string $subject) : AmazonSesClient
Parameters
- $subject : string
-
Subject.
Return values
AmazonSesClientto()
Set Destination email address.
public
to(string $to) : AmazonSesClient
Parameters
- $to : string
-
Destination email address.
Return values
AmazonSesClientclient()
Get SES client instance.
private
client() : SesClient
Return values
SesClient —SES client instance.
reset()
Reset options.
private
reset() : void