PHPackages                             braune-digital/mail-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. braune-digital/mail-bundle

ActiveSymfony-bundle

braune-digital/mail-bundle
==========================

Mail bundle

1.3.x-dev(4y ago)0621MITPHP

Since Sep 24Pushed 4y ago8 watchersCompare

[ Source](https://github.com/braune-digital/BrauneDigitalMailBundle)[ Packagist](https://packagist.org/packages/braune-digital/mail-bundle)[ RSS](/packages/braune-digital-mail-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

BrauneDigitalMailBundle
=======================

[](#braunedigitalmailbundle)

This Symfony2-Bundle allows an easy Management of E-Mail-Templates with additional translations. E-Mails are listed and can be previewed in SonataAdmin.

Installation
------------

[](#installation)

In order to install this Bundle you will need:

- Doctrine ORM (required) -&gt; Entity-Persistence
- SonataEasyExtends (required)
- BrauneDigitalTranslationBaseBundle (required) -&gt; Translations
- SonataAdmin (optional) -&gt; Backend Management

Just run the following command to install this bundle:

```
composer require braune-digital/mail-bundle

```

And enable the Bundle in your AppKernel.php:

```
public function registerBundles()
    {
        $bundles = array(
          ...
          new BrauneDigital\TranslationBaseBundle\BrauneDigitalTranslationBaseBundle(),
          new BrauneDigital\MailBundle\BrauneDigitalMailBundle(),
          ...
        );
```

In order to use the bundle you have to

Extend the Bundle
-----------------

[](#extend-the-bundle)

Just run:

```
php app/console sonata:easy-extends:generate --dest=src BrauneDigitalMailBundle

```

And enable the extended Bundle in your AppKernel.php as well:

```
public function registerBundles()
    {
        $bundles = array(
          ...
          new Application\BrauneDigital\MailBundle\BrauneDigitalMailBundle()
          ...
        );
```

You only need to set the `user_class` option:

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

[](#configuration)

```
braune_digital_mail:
    user_class: Application\Sonata\UserBundle\Entity\User # Path to you used User-Entity
    base_template_path: "emails" #used for template suggestions in SonataAdmin, defaults to "emails", which would resolve to app/Resources/views/emails
    #base_template_path: ["emails_password_reset", "emails_registration] #Can be an array of paths as well
    #base_template_path: ~ #Do not use template suggestions (You would have to enter the path manually)
```

Mail-Templates
--------------

[](#mail-templates)

*emails/confirm.html.twig*:

```
{% extends 'emails/layout.html.twig' %}

{% block body %}
	{{ object.template.body|raw }}
	---USER_NAME{{ object.object.username }}---
	---CONFIRMATION_LINK{% if object.object.confirmationToken is not empty %}{{ url('fos_user_registration_password_confirm', {token: object.object.confirmationToken}) }}{% else %}{{ url('fos_user_registration_password_confirm', {token: 'na'}) }}{% endif %}---
{% endblock %}
```

Where `---USER_NAME{{ object.object.username }}---`would be a generated placeholder with id *USER\_NAME*. An `txt.twig` file is addionally used to append the Content as plain text as well:

*emails/confirm.txt.twig*:

```
{{ object.template.body|raw|striptags }}
---USERNAME{{ object.object.username }}---
---CONFIRMATION_LINK{% if object.object.confirmationToken is not empty %}{{ url('fos_user_registration_password_confirm', {token: object.object.confirmationToken}) }}{% else %}{{ url('fos_user_registration_password_confirm', {token: 'na'}) }}{% endif %}---
```

Placeholders can then be used in the Template-Description (layout path has to be the same):
```
Dear ###USER_NAME###

Thank you for registering. In order to complete your registration, you need to confirm your email address. To do so, click on the following link:

###CONFIRMATION_LINK###

Best regards
```
##Types of Mails
There are currenty two types of Mails:
* Standard Mail
* User Mail (used for mails regarding a single or two users)

## Send Mails
In order to send mails one has to get the template by entering the layout path and creating a new mail:
```php
$layout = 'emails/confirm.html.twig';
$mailService = $this->get('braunedigital.mail.service.mail');
$template = $mailService->getTemplate($layout);

if ($template) {
    $mail = new UserMail();
    $mail->setTemplate($template);
    $mail->setObject($user);
    $mail->setObject2(null);
    //send the mail directly
    $mailService->handle($mail);
    //or store it for later sending
    $em->persist($mail);
    $em->flush();
}
```
The template will now be rendered and the user is available as `object` in the template.
The locale and recipient adress are being loaded from the first user (`object`).
Or for user independent mails:

```php
$layout = 'emails/static_mail.html.twig';
$mailService = $this->get('braunedigital.mail.service.mail');
$template = $mailService->getTemplate($layout);

if ($template) {
    $mail = new Mail();
    $mail->setTemplate($template);
    $mail->setRecipient($email);
    $mail->setLocale('en');
    //send the mail directly
    $mailService->handle($mail);
    //or store it for later sending
    $em->persist($mail);
    $em->flush();
}
```

## SendMailQueueCommand
In order to send mails that have not been handled immediately, the command braunedigital:mails:send has to be executed!

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.2% 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 ~655 days

Total

4

Last Release

1549d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/141b9ae2fba31f3c2d3e58bdb88b88c0ca2824d4821fd8165449459b7f481d6d?d=identicon)[Braune Digital GmbH](/maintainers/Braune%20Digital%20GmbH)

![](https://www.gravatar.com/avatar/b163461896731d880ec200d41ba8fdbff865f72332a098283573461e70591e3d?d=identicon)[pr@braune-digital.com](/maintainers/pr@braune-digital.com)

---

Top Contributors

[![hbraune](https://avatars.githubusercontent.com/u/1439199?v=4)](https://github.com/hbraune "hbraune (25 commits)")[![prathje](https://avatars.githubusercontent.com/u/297476?v=4)](https://github.com/prathje "prathje (4 commits)")

---

Tags

mail bundle

### Embed Badge

![Health badge](/badges/braune-digital-mail-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/braune-digital-mail-bundle/health.svg)](https://phpackages.com/packages/braune-digital-mail-bundle)
```

PHPackages © 2026

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