eightmarq/mail-template-bundle
Mail template bundle for Symfony helps build and send emails from Twig templates or Doctrine. Define reusable MailTypes for registration, password reset and more, with translated subjects, bodies and CTAs, plus overridable MJML-based templates.
## Getting Started
Install the package via Composer:
```bash
composer require schvoy/mail-template-bundle
Publish the configuration file (if needed):
php artisan vendor:publish --provider="Schvoy\MailTemplateBundle\MailTemplateBundleServiceProvider"
First Use Case:
Send a templated email by defining a MailTemplateEntity with either:
content string (inline HTML)templatePath (path to a Blade template)Example:
use Schvoy\MailTemplateBundle\Entity\MailTemplateEntity;
$mailTemplate = new MailTemplateEntity();
$mailTemplate->setTemplatePath(resource_path('views/emails/welcome.blade.php'));
$mailTemplate->setData(['name' => 'John']);
// Pass to your mailer (e.g., Laravel's Mail facade)
Mail::send($mailTemplate);
resources/views/emails/ (or a custom path).MailTemplateEntity for dynamic content or MailTemplateEntityInterface for custom implementations.setData() or constructor injection.Mail facade or a custom mailer service to dispatch.content for one-off emails or templatePath for reusable templates.content or templatePath is set (now enforced in v1.0.1).Schvoy\MailTemplateBundle\Mailer\MailTemplateMailer for additional logic.DoctrineBased tests as a reference for entity mapping.MailTemplateEntityInterface for unit tests.content or templatePath must now be set on MailTemplateEntityInterface. Older code passing empty entities will fail.resource_path('views/emails/...')).setData() keys match template variables (e.g., {{ $name }} requires ['name' => '...']).MailTemplateEntityInterface for alternative data sources (e.g., database-backed templates).resources/views/emails/. Override via config:
'template_paths' => [
resource_path('views/custom-emails'),
],
Schvoy\MailTemplateBundle\Entity\AbstractMailTemplateEntity.
NO_UPDATE_NEEDED would **not** apply here due to the breaking change and new enforcement in v1.0.1.
How can I help you explore Laravel packages today?