- Issue created by @adamps
- Issue was unassigned.
Part of stage 2 of 🌱 [META] Adopt the symfony mailer component Needs review . Create a new API with direct access to all the power of Symfony Mailer. Enhances the symfony code with integration into Drupal mechanisms, including theme/template/render, multi-language, CSS libraries, configuration, plug-ins, hooks, and logging.
1) New service 'mailer'
Thin wrapper on top of Symfony\Component\Mailer\Mailer
Mailer
implements MailerInterface
send(EmailInterface $email)
- similar to base Mailer
classcreate(string $type, string $sub_type, array $params);
that returns EmailInterface
mail(string $type, string $sub_type, array $params);
that creates and sends, delegating all building to an "Email Builder" - similar to MailManagerInterface
Main responsibilities:
2) New class Email
implements EmailInterface
This would enhance the symfony base class with some new fields:
We need to make some changes to the base class. For example the base function subject(string $subject)
would force translation too soon, before the right language has been selected.
3) Callbacks: events and processors
The email building pipeline has the following phases: build, render, post-render, send, post-send. The ones in italics are done by the Mailer, the others are done by code that builds/alters emails. For the latter case, there are two options:
EmailProcessorInterface
, which has a function for each phaseAll the events and functions have a single argument/member of type EmailInterface
.
4) Email Builder
Implemented by a module to send emails (resembling the old hook_mail()
callback). This is optional and modules can also build mails directly.
@EmailBuilder
with classes implementing EmailProcessorInterface
EmailBuilderManager
implementing EmailBuilderManagerInterface
Questions:
1) Should we create a new module mailer
, initially experimental?
2) Should the new class Email extend the base symfony one, or decorate it (meaning have a class variable $inner containing the base class)?
None
See proposed resolution
None