Skip to content

Commit e6d0528

Browse files
committed
Issue #104: how to send an email and parse the content
Signed-off-by: horea <[email protected]>
1 parent a0b49b1 commit e6d0528

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/book/v6/core-features/rendering-and-sending-emails.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Rendering and sending emails
22

3-
In the previous versions of Dotkernel API we have been composing email bodies using **Twig** from the `mezzio/mezzio-twigrenderer` package.\
3+
In the previous versions of Dotkernel API we have been composing email bodies using **Twig** from the `mezzio/mezzio-twigrenderer` package.
44
In the current version of Dotkernel API, we introduced the core mail service `Core/src/App/src/Service/MailService` which is responsible for sending all emails.
55

6-
Being a core service, `MailService` is used across all projects implementing the Core architecture.\
6+
Being a core service, `MailService` is used across all projects implementing the Core architecture.
77
To compose and send an email, a solid implementation of `TemplateRendererInterface` was required to be injected into `MailService`, because each method rendered and parsed their respective templates in place before sending an email.
88
This is acceptable with other Dotkernel applications which in most cases return a rendered template, but being that Dotkernel API mostly returns JSON objects, rendered with a different renderer, **Twig** had to be replaced with a lighter solution.
99

10-
The solution is a custom [`Api\App\Template\Renderer`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/Renderer.php) implementing [`Api\App\Template\RendererInterface`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/RendererInterface.php).\
10+
The solution is a custom [`Api\App\Template\Renderer`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/Renderer.php) implementing [`Api\App\Template\RendererInterface`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/RendererInterface.php).
1111
This is a lightweight renderer, aimed at rendering a combination of **PHP** and **HTML** files with `phtml` extension.
1212

13-
With the new solution, `MailService` requires no implementation of any renderer because it no longer has to render templates internally.\
13+
With the new solution, `MailService` requires no implementation of any renderer because it no longer has to render templates internally.
1414
Instead, an implementation of `Api\App\Template\RendererInterface` is first injected in the handler:
1515

1616
```php
1717
class ExampleHandler extends AbstractHandler
1818
{
1919
#[Inject(
20-
MailService::class,
21-
RendererInterface::class,
20+
MailService::class,
21+
RendererInterface::class,
2222
)]
2323
public function __construct(
2424
protected MailService $mailService,
@@ -41,4 +41,4 @@ And finally, the handler calls the mail service with the composed $body being pa
4141
$this->mailService->sendWelcomeMail($user, $body);
4242
```
4343

44-
>Other Dotkernel applications implementing the Core architecture do the same in the handlers, but keep using Twig as the template renderer.
44+
> Other Dotkernel applications implementing the Core architecture do the same in the handlers, but keep using Twig as the template renderer.

0 commit comments

Comments
 (0)