{"id":18781537,"url":"https://github.com/devture/symfony-email-template-bundle","last_synced_at":"2025-07-19T19:39:53.638Z","repository":{"id":56967216,"uuid":"119440204","full_name":"devture/symfony-email-template-bundle","owner":"devture","description":"Symfony bundle providing Twig-based email-template management (persisted to the filesystem) and message preparation.","archived":false,"fork":false,"pushed_at":"2024-01-10T09:13:32.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-15T06:49:56.805Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devture.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-29T20:53:04.000Z","updated_at":"2024-01-05T18:09:58.000Z","dependencies_parsed_at":"2024-11-07T20:44:50.381Z","dependency_job_id":null,"html_url":"https://github.com/devture/symfony-email-template-bundle","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"c03151a5bbe7ebc83dd42215d4fd08424368bd70"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/devture/symfony-email-template-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fsymfony-email-template-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fsymfony-email-template-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fsymfony-email-template-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fsymfony-email-template-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devture","download_url":"https://codeload.github.com/devture/symfony-email-template-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fsymfony-email-template-bundle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263832490,"owners_count":23517351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T20:32:16.069Z","updated_at":"2025-07-06T00:38:41.496Z","avatar_url":"https://github.com/devture.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\n\nBundle providing:\n\n- a web UI for managing email templates\n- system for preparing [symfony/mailer](https://symfony.com/doc/current/mailer.html) email messages out of these templates. See [Usage](#usage).\n\nEmail Templates managed by this bundle are [Twig](http://twig.sensiolabs.org/) templates,\nwhich you edit through the web UI. Each \"template\" can be localized to multiple languages.\n\nThe templates are stored on the filesystem as [YAML](https://en.wikipedia.org/wiki/YAML) files using [Gaufrette](http://knplabs.github.io/Gaufrette/).\nThis allows you to version-control them along with your project's source code.\n\n\n# Prerequisites\n\nThis bundles depends on [devture/form](https://packagist.org/packages/devture/form).\n\nBefore you can get this bundle working, you'd need a working `devture/form` setup.\n\nMinimally, you need to define the following services somewhere (possibly in a `devture-form.yaml` file in your `AppBundle`):\n\n```yaml\nservices:\n  _defaults:\n    autowire: true\n    autoconfigure: true\n    public: false\n\n  Devture\\Component\\Form\\Token\\TemporaryTokenManager:\n    arguments:\n      $validityTime: 3600\n      $secret: \"%env(APP_SECRET)%\"\n      $hashFunction: sha256\n\n  Devture\\Component\\Form\\Token\\TokenManagerInterface:\n    alias: Devture\\Component\\Form\\Token\\TemporaryTokenManager\n\n  Devture\\Component\\Form\\Twig\\FormExtension:\n    tags: [twig.extension]\n\n  Devture\\Component\\Form\\Twig\\TokenExtension:\n    tags: [twig.extension]\n```\n\nAdditionally, 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\"`\n\n\n# Installation\n\nInstall through composer (`composer require devture/symfony-email-template-bundle`).\n\nAdd to `config/bundles.php`:\n\n```php\nDevture\\Bundle\\EmailTemplateBundle\\DevtureEmailTemplateBundle::class =\u003e ['all' =\u003e true],\n```\n\n\n## Configuration\n\nYou can drop the following configuration in `config/packages/devture_email_template.yaml`\n\n```yaml\ndevture_email_template:\n  email_template_storage_path: \"%kernel.project_dir%/asset/email-template\"\n  locales:\n    - {\"key\": \"en\", \"name\": \"English\"}\n    - {\"key\": \"ja\", \"name\": \"Japanese\"}\n  fallback_locale_key: en\n  email_wrapper_path: \"@DevtureEmailTemplate/email-wrapper.html.twig\"\n  webui_twig_layout_path: \"base.html.twig\"\n  editable: \"%kernel.debug%\"\n```\n\n`email_template_storage_path` is the directory where the templates would be stored. It needs to be writable by your web server user.\n\n`locales` needs to contain all languages that you're translating your email templates to.\n\n`fallback_locale_key` specifies which language to fall back to in case a template is not available in the language requested.\n\n`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.\n\n`webui_twig_layout_path` is the path to your layout file, which would contain the email template system's web UI.\nThe 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.\n\nExample layout file:\n\n```twig\n\u003c!doctype html\u003e\n\u003chtml\u003e\n\t\u003cbody\u003e\n\t\t\u003ch1\u003eWebsite\u003c/h1\u003e\n\t\t{% block content %}{% endblock %}\n\n\t\t\u003cscript type=\"text/javascript\"\u003e\n\t\t\t{% block js %}{% endblock %}\n\t\t\u003c/script\u003e\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n`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.\n\n\n## Routing example\n\nYou most likely want this bundle's web UI active only for your development (`dev`) environment.\nThus, you can drop the following routing config in `config/routes/dev/DevtureEmailTemplateBundle.yaml`:\n\n```yaml\nDevtureEmailTemplateBundleWebsite:\n    prefix: /{_locale}/email-template\n    resource: \"@DevtureEmailTemplateBundle/Resources/config/routes/website.yaml\"\n    requirements:\n        _locale: \"en|ja\"\n```\n\nThe Web UI is available at the `devture_email_template.manage` route.\n\n\n## Web UI\n\nTemplates can be edited as HTML (they're Twig \"files\", after all).\nThis bundle relies on [CKEDITOR 4](https://ckeditor.com/ckeditor-4/) as a rich-text editor.\n\nYou can load it somewhere in your `webui_twig_layout_path` template file with a regular `\u003cscript\u003e` tag.\n\nAlternatively, you can load it via [comploader](https://github.com/spantaleev/comploader) by definining it as a library named `ckeditor4`, like this:\n\n```html\n\u003cscript\u003e\ncomploader.register(\"ckeditor4\", {\n\t\"scripts\": [\n\t\t{\n\t\t\t\"url\": \"https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.8.0/ckeditor.js\",\n\t\t\t\"integrity\": \"sha384-O5mWK3ANYOTVEe9IPtX3AglPo9YiJ4txOJlcCuY1DJf9Bawr3wUvQiVe1H5NvNlh\"\n\t\t}\n\t]\n});\n\u003c/script\u003e\n```\n\n\n## Styling\n\nThis bundle relies on [Bootstrap](http://getbootstrap.com/) v4 for styling.\nUnless you install and include it (somewhere in your `webui_twig_layout_path` template), things would look ugly.\n\nAdditionally, 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.\n\n```html\n\u003cstyle\u003e\n\t.devture-email-template-flag {\n\t\tborder: 1px solid #dbdbdb;\n\t\twidth: 20px;\n\t\theight: 13px;\n\t\tdisplay: inline-block;\n\t\tvertical-align: text-top;\n\t}\n\t.devture-email-template-flag.en {\n\t\tbackground: url('/images/flag/en_US.png') no-repeat;\n\t}\n\t.devture-email-template-flag..ja {\n\t\tbackground: url('/images/flag/ja_JP.png') no-repeat;\n\t}\n\u003c/style\u003e\n```\n\n# Usage\n\nSuppose you have created a template called `user/registered`, which contains some content like this:\n\n```twig\nHello {{ user.name }}!\n\nWelcome to \u003ca href=\"{{ path('homepage') }}\"\u003eour website\u003c/a\u003e!\n```\n\nTo send an email using this template you'd do this:\n\n```php\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Devture\\Bundle\\EmailTemplateBundle\\Helper\\MessageCreator;\n\nclass UserRegistrationController extends AbstractController {\n\n\tpublic function register(Request $request, MessageCreator $messageCreator, \\Swift_Mailer $mailer) {\n\t\t// Actually handle registration here..\n\t\t$user = $this-\u003eregisterUser($request);\n\n\t\t$templateData = [\n\t\t\t'user' =\u003e $user,\n\t\t];\n\t\t$message = $messageCreator-\u003ecreateMessage('user/registered', $request-\u003egetLocale(), $templateData);\n\n\t\t// Set these..\n\t\t$message-\u003efrom($senderAddress);\n\t\t$message-\u003eto($receiverAddress);\n\n\t\t$mailer-\u003esend($message);\n\t}\n\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevture%2Fsymfony-email-template-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevture%2Fsymfony-email-template-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevture%2Fsymfony-email-template-bundle/lists"}