{"id":15287370,"url":"https://github.com/975l/emailbundle","last_synced_at":"2025-09-01T06:33:48.900Z","repository":{"id":49330497,"uuid":"93390936","full_name":"975L/EmailBundle","owner":"975L","description":"Bundle to manage sending emails and store in a database","archived":false,"fork":false,"pushed_at":"2025-03-09T15:44:59.000Z","size":199,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T05:09:43.381Z","etag":null,"topics":["swiftmailer","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"https://975l.com/en/pages/email-bundle","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/975L.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"zenodo":null},"funding":{"github":null,"patreon":"LaurentMarquet","open_collective":"laurent-marquet","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://buymeacoff.ee/laurentmarquet"}},"created_at":"2017-06-05T10:04:26.000Z","updated_at":"2025-03-09T15:45:01.000Z","dependencies_parsed_at":"2024-10-14T18:21:16.350Z","dependency_job_id":"4238f1fc-a07c-4b10-8890-2aab413646e5","html_url":"https://github.com/975L/EmailBundle","commit_stats":{"total_commits":91,"total_committers":3,"mean_commits":"30.333333333333332","dds":0.05494505494505497,"last_synced_commit":"3dc8838d6c47f527f21b3614c22be8ea797c289c"},"previous_names":[],"tags_count":91,"template":false,"template_full_name":null,"purl":"pkg:github/975L/EmailBundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/975L%2FEmailBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/975L%2FEmailBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/975L%2FEmailBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/975L%2FEmailBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/975L","download_url":"https://codeload.github.com/975L/EmailBundle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/975L%2FEmailBundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273082421,"owners_count":25042282,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["swiftmailer","symfony","symfony-bundle"],"created_at":"2024-09-30T15:27:57.752Z","updated_at":"2025-09-01T06:33:48.834Z","avatar_url":"https://github.com/975L.png","language":"PHP","funding_links":["https://patreon.com/LaurentMarquet","https://opencollective.com/laurent-marquet","https://buymeacoff.ee/laurentmarquet"],"categories":[],"sub_categories":[],"readme":"# EmailBundle\n\nEmailBundle does the following:\n\n- Stores email in a database as an option,\n- Sends email using [Symfony Mailer](https://github.com/symfony/mailer),\n- Allows user with good ROLE to see emails sent,\n- Defines a template for emails that should be overriden to integrate fully with website,\n- Allows to attach one or multiple files.\n\n[EmailBundle dedicated web page](https://975l.com/en/pages/email-bundle).\n\n[EmailBundle API documentation](https://975l.com/apidoc/c975L/EmailBundle.html).\n\n## Bundle installation\n\n### Step 1: Download the Bundle\n\nUse [Composer](https://getcomposer.org) to install the library\n\n```bash\n    composer require c975l/email-bundle\n```\n\n### Step 2: Enable the Bundle\n\nThen, enable the bundle by adding it to the list of registered bundles in the `app/AppKernel.php` file of your project:\n\n```php\n\u003c?php\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        $bundles = [\n            // ...\n            new c975L\\EmailBundle\\c975LEmailBundle(),\n        ];\n    }\n}\n```\n\n### Step 3: Configure the Bundle\n\nCheck dependencies for their configuration:\n\n- [Symfony Mailer](https://github.com/symfony/mailer)\n- [Doctrine](https://github.com/doctrine/DoctrineBundle)\n- [KnpPaginatorBundle](https://github.com/KnpLabs/KnpPaginatorBundle)\n\nc975LEmailBundle uses [c975L/ConfigBundle](https://github.com/975L/ConfigBundle) to manage configuration parameters. Use the Route \"/email/config\" with the proper user role to modify them.\n\n**If you are NOT using Messenger** remember to disable the contents in config/packages/messenger.yaml or configure it properly.\n\n### Step 4: Enable the Routes\n\nThen, enable the routes by adding them to the `app/config/routing.yml` file of your project:\n\n```yml\nc975_l_email:\n    resource: \"@c975LEmailBundle/Controller/\"\n    type: annotation\n    prefix: /\n    #Multilingual website use the following\n    #prefix: /{_locale}\n    #defaults:   { _locale: '%locale%' }\n    #requirements:\n    #    _locale: en|fr|es\n```\n\n### Step 4: Create MySql table\n\nYou can use `php bin/console make:migration` to create the migration file as documented in [Symfony's Doctrine docs](https://symfony.com/doc/current/doctrine.html) OR use `/Resources/sql/emails.sql` to create the tables `emails` and `emails_archives`. The `DROP TABLE` are commented to avoid dropping by mistake. It will also create a stored procedure `sp_EmailsArchive()` and an event `e_monthly_archives` to archives emails older than 90 days. If you don't want to use this feature, just remove them.\n\n### Step 5: Create MySql table\n\nHave a look at the following links if you wish to use [Symfony Messenger](https://symfony.com/doc/current/messenger.html) to dispatch messages with [Doctrine](https://symfony.com/doc/current/messenger.html#doctrine-transport). If you want to use async you may also have a look at [this answer on StackOverflow](https://stackoverflow.com/a/73547566/6028808).\n\n### How to use\n\nCreate a Twig template i.e. `templates/emails/description.html.twig` with this content:\n\n```twig\n{# If you want to use the template provided by c975LEmailBundle you have to extend its layout #}\n{% extends \"@c975LEmail/emails/layout.html.twig\" %}\n\n{% block email_content %}\n    \u003cp\u003e\n        {{ 'label.description'|trans }} : \u003cstrong\u003e{{ object.description }}\u003c/strong\u003e\n    \u003c/p\u003e\n{# You can include files #}\n    {% include 'YOUR_FILE_PATH' %}\n{% endblock %}\n```\n\nThen in your Controller, add this code to create, insert in DB and send your email:\n\n```php\n\u003c?php\n// src/Controller/AnyController.php\n\nuse c975L\\EmailBundle\\Service\\EmailServiceInterface;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\n\nclass AnyController extends AbstractController\n{\n    public function anyFunction(Request $request, EmailServiceInterface $emailService)\n    {\n        // ...\n\n        //Build your email\n        $body = $this-\u003erenderView('emails/description.html.twig', array(\n            //Data needed for your template\n            ));\n        $emailData = array(\n            'subject' =\u003e 'YOUR_SUBJECT',\n            'sentFrom' =\u003e $emailService-\u003egetParameter('c975LEmail.sentFrom'),\n            'sentTo' =\u003e 'contact@example.com',\n            'sentCc' =\u003e 'contact@example.com', //optional\n            'sentBcc' =\u003e 'contact@example.com', //optional\n            'replyTo' =\u003e 'contact@example.com', //optional\n            'body' =\u003e $body,\n            'attach' =\u003e array(\n                array($filePath, $filename, $contentType),\n            ), //optional\n            'ip' =\u003e $request-\u003egetClientIp(), //optional\n            );\n\n        //Sends email\n        $emailSent = $emailService-\u003esend($emailData, [saveDatabase ? true|false(default)]);\n\n        //You can test if email has been sent\n        if ($emailSent) {\n            //Do what you need...\n        } else {\n            //Do what you need...\n        }\n\n        // ...\n    }\n}\n```\n\n### Email messages templates\n\nIf you wish to override/disable a block defined in the `fullLayout.html.twig` template, create your `templates/bundles/c975LEmailBundle/emails/layout.html.twig` and use the following code:\n\n```twig\n{% extends \"@c975LEmail/emails/fullLayout.html.twig\" %}\n\n{# Overide a block #}\n{% block noSpam %}\n    {# You can also use {{ parent() }} #}\n    {# YOUR_OWN_TEXT #}\n{% endblock %}\n\n{# Disable a block #}\n{% block logo %}\n{% endblock %}\n```\n\nHave a look at `templates/emails/fullLayout.html.twig`, to see all available blocks.\n\n### Footer template\n\nYou should override the template `templates/emails/footer.html.twig` in your `templates/bundles/c975LEmailBundle/emails/footer.html.twig` and indicate there all the data you need to display at the bottom of sent email.\n\n### Use of dashboard and display messages sent\n\nYou can see the emails sent via the dashboard.\n\nFor this, simply, create the following structure `templates/bundles/c975LEmailBundle/` in your app and then duplicate the file `layout.html.twig` in it, to override the existing Bundle files, then apply your needed changes.\n\nIn `layout.html.twig`, it will mainly consist to extend your layout and define specific variables, i.e. :\n\n```twig\n{% extends 'layout.html.twig' %}\n{# or extends 'emails/layout.html.twig' #}\n\n{# Defines specific variables #}\n{% set title = 'Email (' ~ title ~ ')' %}\n\n{% block content %}\n    {% block email_content %}\n    {% endblock %}\n{% endblock %}\n```\n\nIf this project **help you to reduce time to develop**, you can sponsor me via the \"Sponsor\" button at the top :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F975l%2Femailbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F975l%2Femailbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F975l%2Femailbundle/lists"}