PHPackages                             devture/symfony-email-template-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. devture/symfony-email-template-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

devture/symfony-email-template-bundle
=====================================

Symfony bundle providing Twig-based email-template management (persisted to the filesystem) and message preparation.

2.2.4(2y ago)21.9k↓90.2%BSD-3-ClausePHPPHP &gt;=8.1

Since Jan 29Pushed 2y ago2 watchersCompare

[ Source](https://github.com/devture/symfony-email-template-bundle)[ Packagist](https://packagist.org/packages/devture/symfony-email-template-bundle)[ RSS](/packages/devture-symfony-email-template-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (16)Used By (0)

Description
===========

[](#description)

Bundle providing:

- a web UI for managing email templates
- system for preparing [symfony/mailer](https://symfony.com/doc/current/mailer.html) email messages out of these templates. See [Usage](#usage).

Email Templates managed by this bundle are [Twig](http://twig.sensiolabs.org/) templates, which you edit through the web UI. Each "template" can be localized to multiple languages.

The templates are stored on the filesystem as [YAML](https://en.wikipedia.org/wiki/YAML) files using [Gaufrette](http://knplabs.github.io/Gaufrette/). This allows you to version-control them along with your project's source code.

Prerequisites
=============

[](#prerequisites)

This bundles depends on [devture/form](https://packagist.org/packages/devture/form).

Before you can get this bundle working, you'd need a working `devture/form` setup.

Minimally, you need to define the following services somewhere (possibly in a `devture-form.yaml` file in your `AppBundle`):

```
services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: false

  Devture\Component\Form\Token\TemporaryTokenManager:
    arguments:
      $validityTime: 3600
      $secret: "%env(APP_SECRET)%"
      $hashFunction: sha256

  Devture\Component\Form\Token\TokenManagerInterface:
    alias: Devture\Component\Form\Token\TemporaryTokenManager

  Devture\Component\Form\Twig\FormExtension:
    tags: [twig.extension]

  Devture\Component\Form\Twig\TokenExtension:
    tags: [twig.extension]
```

Additionally, your `config/packages/twig.yaml` needs to have this additional path added to it: `"%kernel.project_dir%/vendor/devture/form/src/Devture/Component/Form/Resources/views"`

Installation
============

[](#installation)

Install through composer (`composer require devture/symfony-email-template-bundle`).

Add to `config/bundles.php`:

```
Devture\Bundle\EmailTemplateBundle\DevtureEmailTemplateBundle::class => ['all' => true],
```

Configuration
-------------

[](#configuration)

You can drop the following configuration in `config/packages/devture_email_template.yaml`

```
devture_email_template:
  email_template_storage_path: "%kernel.project_dir%/asset/email-template"
  locales:
    - {"key": "en", "name": "English"}
    - {"key": "ja", "name": "Japanese"}
  fallback_locale_key: en
  email_wrapper_path: "@DevtureEmailTemplate/email-wrapper.html.twig"
  webui_twig_layout_path: "base.html.twig"
  editable: "%kernel.debug%"
```

`email_template_storage_path` is the directory where the templates would be stored. It needs to be writable by your web server user.

`locales` needs to contain all languages that you're translating your email templates to.

`fallback_locale_key` specifies which language to fall back to in case a template is not available in the language requested.

`email_wrapper_path` is a layout file for the actual email message. A sample one is provided in the bundle (`@DevtureEmailTemplate/email-wrapper.html.twig`), but feel free to make your own.

`webui_twig_layout_path` is the path to your layout file, which would contain the email template system's web UI. The only requirement is that it defines a `content` block and a `js` block. The translation system would render its HTML content within the `content` block and its JS code within the `js` block.

Example layout file:

```

		Website
		{% block content %}{% endblock %}

			{% block js %}{% endblock %}

```

`editable` controls whether the templates are editable through the web UI or if they'd be displayed as readonly. In any case, your production environment would not even mount the web UI routes, thus preventing all edits.

Routing example
---------------

[](#routing-example)

You most likely want this bundle's web UI active only for your development (`dev`) environment. Thus, you can drop the following routing config in `config/routes/dev/DevtureEmailTemplateBundle.yaml`:

```
DevtureEmailTemplateBundleWebsite:
    prefix: /{_locale}/email-template
    resource: "@DevtureEmailTemplateBundle/Resources/config/routes/website.yaml"
    requirements:
        _locale: "en|ja"
```

The Web UI is available at the `devture_email_template.manage` route.

Web UI
------

[](#web-ui)

Templates can be edited as HTML (they're Twig "files", after all). This bundle relies on [CKEDITOR 4](https://ckeditor.com/ckeditor-4/) as a rich-text editor.

You can load it somewhere in your `webui_twig_layout_path` template file with a regular `` tag.

Alternatively, you can load it via [comploader](https://github.com/spantaleev/comploader) by definining it as a library named `ckeditor4`, like this:

```

comploader.register("ckeditor4", {
	"scripts": [
		{
			"url": "https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.8.0/ckeditor.js",
			"integrity": "sha384-O5mWK3ANYOTVEe9IPtX3AglPo9YiJ4txOJlcCuY1DJf9Bawr3wUvQiVe1H5NvNlh"
		}
	]
});

```

Styling
-------

[](#styling)

This bundle relies on [Bootstrap](http://getbootstrap.com/) v4 for styling. Unless you install and include it (somewhere in your `webui_twig_layout_path` template), things would look ugly.

Additionally, you can make the pages look prettier by including a flag icon for each language somewhere in your `webui_twig_layout_path` template or CSS file.

```

	.devture-email-template-flag {
		border: 1px solid #dbdbdb;
		width: 20px;
		height: 13px;
		display: inline-block;
		vertical-align: text-top;
	}
	.devture-email-template-flag.en {
		background: url('/images/flag/en_US.png') no-repeat;
	}
	.devture-email-template-flag..ja {
		background: url('/images/flag/ja_JP.png') no-repeat;
	}

```

Usage
=====

[](#usage)

Suppose you have created a template called `user/registered`, which contains some content like this:

```
Hello {{ user.name }}!

Welcome to our website!
```

To send an email using this template you'd do this:

```
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Devture\Bundle\EmailTemplateBundle\Helper\MessageCreator;

class UserRegistrationController extends AbstractController {

	public function register(Request $request, MessageCreator $messageCreator, \Swift_Mailer $mailer) {
		// Actually handle registration here..
		$user = $this->registerUser($request);

		$templateData = [
			'user' => $user,
		];
		$message = $messageCreator->createMessage('user/registered', $request->getLocale(), $templateData);

		// Set these..
		$message->from($senderAddress);
		$message->to($receiverAddress);

		$mailer->send($message);
	}

}
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~155 days

Recently: every ~95 days

Total

15

Last Release

906d ago

Major Versions

1.1 → 2.02022-12-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/9daf523f8e47ddeb8af23183c06721c4e89111eb4eb3f9ce264242b373e9dd80?d=identicon)[spantaleev](/maintainers/spantaleev)

---

Top Contributors

[![spantaleev](https://avatars.githubusercontent.com/u/388669?v=4)](https://github.com/spantaleev "spantaleev (22 commits)")

---

Tags

symfonybundleemailtemplate

### Embed Badge

![Health badge](/badges/devture-symfony-email-template-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/devture-symfony-email-template-bundle/health.svg)](https://phpackages.com/packages/devture-symfony-email-template-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
