PHP code example of sunaoka / laravel-ses-template-driver
1. Go to this page and download the library: Download sunaoka/laravel-ses-template-driver library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sunaoka / laravel-ses-template-driver example snippets
'default' => 'sestemplate',
'mailers' => [
'sestemplate' => [
'transport' => 'sestemplate', // or `sesv2template` - When using Amazon SES API v2
],
],
use Illuminate\Support\Facades\Mail;
use Sunaoka\LaravelSesTemplateDriver\Mail\SesTemplate;
class Foo
{
public function sendmail()
{
$templateName = 'MyTemplate';
$templateData = [
'name' => 'Alejandro',
'favoriteanimal' => 'alligator',
];
$result = Mail::to('[email protected]')
->cc('[email protected]')
->bcc('[email protected]')
->send(new SesTemplate($templateName, $templateData));
echo $result->getMessageId(); // Message-ID overwritten by Amazon SES
}
}
use Illuminate\Mail\Mailables\Address;
use Illuminate\Support\Facades\Mail;
use Sunaoka\LaravelSesTemplateDriver\Mail\SesTemplate;
use Sunaoka\LaravelSesTemplateDriver\Mail\SesTemplateOptions;
class Foo
{
public function sendmail()
{
$templateName = 'MyTemplate';
$templateData = [
'name' => 'Alejandro',
'favoriteanimal' => 'alligator',
];
$options = new SesTemplateOptions();
$options->from(new Address('[email protected]', 'Alejandro Rosalez'))
->replyTo(new Address('[email protected]'));
// Only with Amazon SES API v2 ('transport' is `sesv2template`)
$options->header('X-Custom-Header1', 'Custom Value 1')
->header('X-Custom-Header2', 'Custom Value 2');
// You can also set it in the constructor.
$options = new SesTemplateOptions(
from: new Address('[email protected]', 'Alejandro Rosalez'),
replyTo: new Address('[email protected]'),
headers: [
'X-Custom-Header1' => 'Custom Value 1',
'X-Custom-Header2' => 'Custom Value 2',
],
);
$result = Mail::to('[email protected]')
->cc('[email protected]')
->bcc('[email protected]')
->send(new SesTemplate($templateName, $templateData, $options));
echo $result->getMessageId(); // Message-ID overwritten by Amazon SES
}
}