Last active
June 16, 2025 15:12
-
-
Save tuanpht/83d021434086878d30ef8e4516cc11b5 to your computer and use it in GitHub Desktop.
Revisions
-
Pham Tuan renamed this gist
Sep 13, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Pham Tuan revised this gist
Sep 13, 2018 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,9 +55,7 @@ 'Destinations' => [ [ 'Destination' => [ 'ToAddresses' => ['[email protected]'], ], 'ReplacementTemplateData' => json_encode([ 'name' => 'ABC', @@ -66,9 +64,7 @@ ], [ 'Destination' => [ 'ToAddresses' => ['[email protected]'], ], 'ReplacementTemplateData' => json_encode([ 'name' => 'DEF', -
Pham Tuan revised this gist
Sep 13, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php use Aws\Ses\SesClient; use Illuminate\Mail\Markdown; -
Pham Tuan created this gist
Sep 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ @component('mail::message') Hello @{{ name }}, We want to say: @{{ message }}. @endcomponent This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ Hello {{ name }}, We want to say: {{ message }}. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ use Aws\Ses\SesClient; use Illuminate\Mail\Markdown; // Create SES client $ses = new SesClient([ 'credentials' => [ 'key' => config('services.ses.key'), 'secret' => config('services.ses.secret'), ], 'region' => config('services.ses.region'), 'version' => 'latest', ]); // Render email content from markdown... $markdown = new Markdown(view(), config('mail.markdown')); $htmlContent = $markdown->render('hello_template'); $textContent = $markdown->renderText('hello_template'); // Create template $ses->createTemplate([ 'Template' => [ 'TemplateName' => 'hello_template', 'HtmlPart' => $htmlContent, 'TextPart' => $textContent, 'SubjectPart' => 'Hello {{ name }}', ], ]); // Update if necessary /* $ses->updateTemplate([ 'Template' => [ 'TemplateName' => 'hello_template', 'HtmlPart' => $htmlContent, 'SubjectPart' => 'Hello {{ name }}', ], ]); */ // Test content before send /* echo $ses->testRenderTemplate([ 'TemplateName' => 'hello_template', 'TemplateData' => json_encode([ 'name' => 'Mr A', 'message' => 'Thank you!', ]), ]); */ $ses->sendBulkTemplatedEmail([ 'Source' => sprintf('%s <%s>', config('mail.from.name'), config('mail.from.address')), 'Template' => 'hello_template', 'DefaultTemplateData' => json_encode([ 'name' => 'DEFAULT', 'placeholder' => 'DEFAULT', ]), 'Destinations' => [ [ 'Destination' => [ 'ToAddresses' => [ '[email protected]', ], ], 'ReplacementTemplateData' => json_encode([ 'name' => 'ABC', 'message' => 'Bonjua', ]), ], [ 'Destination' => [ 'ToAddresses' => [ '[email protected]', ], ], 'ReplacementTemplateData' => json_encode([ 'name' => 'DEF', 'message' => 'Merci', ]), ], ], ]);