PHPackages                             maba/mail-renderer-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. [Mail &amp; Notifications](/categories/mail)
4. /
5. maba/mail-renderer-bundle

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

maba/mail-renderer-bundle
=========================

Symfony bundle for easier email sending

1.1.1(10y ago)094MITPHPPHP &gt;=5.3.3

Since Jun 23Pushed 10y ago1 watchersCompare

[ Source](https://github.com/mariusbalcytis/mail-renderer-bundle)[ Packagist](https://packagist.org/packages/maba/mail-renderer-bundle)[ RSS](/packages/maba-mail-renderer-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

Mail Renderer Bundle
====================

[](#mail-renderer-bundle)

Symfony bundle that collects some libraries together to make sending emails easier:

1. Renders twig template to get subject and content of an email
2. Converts HTML content to plain text if it's not available in template
3. Sets default From email and name to message
4. Gets CSS for mail messages using Assetic, if configured
5. Inlines CSS inside HTML `style` attributes and/or adds `` tag
6. Sends message using swift mailer

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

[](#installation)

Add via composer:

```
composer require maba/mail-renderer-bundle jimbojsb/emogrify:@dev

```

Register bundle:

```
new Maba\Bundle\MailRendererBundle\MabaMailRendererBundle(),
```

Configure in `config.yml`:

```
maba_mail_renderer:
    css_assets:
        inline: mail
        imports: mail_imports
    from:
        email: info@example.com
        name: My Awesome Company

assetic:
    assets:
        mail:
            inputs:
                - @bootstrap_css
                - @ApplicationBundle/Resources/less/styles.less
        mail_imports:
            inputs:
                - %kernel.root_dir%/Resources/public/css/mail-imports.css
```

`css_assets` node is optional, as is usage of Assetic.

Usage
-----

[](#usage)

Code:

```
/** @var FormattedMessageMailer $mailer */
$mailer = $this->get('maba_mail_renderer.formatted_message_mailer');

$mailer->sendMessage('customer@example.com', 'ApplicationBundle:Email:welcome.html.twig', array(
    'username' => 'customer123',
    'activationLink' => 'http://www.example.com/activate/ABC123',
));
```

Twig template:

```
{# ApplicationBundle:Email:welcome.html.twig #}

{% block subject %}Hello {{ username }}, welcome to example.com!{% endblock %}

{% block body_html %}
    Hello {{ username }},

        You've registered on example.com. Here you can make lots of stuff:

            Stuff
            More stuff

        To activate your account click here

    See ya!
{% endblock %}
```

That's it!

All CSS rules assigned to classes will be inlined into HTML as `style` attributes.

Extended usage
--------------

[](#extended-usage)

### Templates

[](#templates)

Only these blocks are parsed from template: `subject`, `body_html` and `body_text`. `subject` and at least one of other two are required. Any other blocks or content in template is ignored.

If `body_text` is provided, it will be used as plain text version of mailer message.

Additionally `toEmail` variable is passed to the twig template, which equals to the given recipient.

I'd suggest to use single layout twig file, if there's defined structure in your mails. For example:

```
{# :Email:layout.html.twig #}

{% block body_html %}
    Good afternoon,

    {% block content %}{% endblock %}

    See ya!

    Unsubscribe
{% endblock %}
```

```
{# ApplicationBundle:Email:welcome.html.twig #}
{% extends ':Email:layout.html.twig' %}

{% block subject %}...{% endblock %}
{% block content %}
    ...
{% endblock %}
```

### Styles

[](#styles)

`inline` and `imports` values in `css_assets` configuration node take Assetic asset name, which you should configure using Assetic configuration.

`inline` is used when applying CSS rules to message HTML result - `style` attributes are added to HTML nodes, which would trigger appropriate CSS rules. This is needed as some email readers support neither `` nor ``(for example GMail).

`imports` is used to make `` tag with CSS contents in the mail message itself. This should be as short as possible - usually only for rules that cannot be inlined, like this one:

```
@import url("//fonts.googleapis.com/css?family=Ubuntu:400,400italic,700,700italic&subset=latin,latin-ext");
```

That's why it's called `imports` in configuration.

Why `` instead of ``? To avoid remote resource loading, which is also most commonly disabled by default.

### Changing created message

[](#changing-created-message)

Use `createMessage` instead of `sendMessage` with same parameters in renderer, change or add any required fields and send with swift mailer manually.

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~95 days

Total

3

Last Release

3883d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e131c9aa5f5a4fc3cc2f5e01b377ef33bbc3468acc95ff890fc6e8353d9cf67?d=identicon)[mariusbalcytis](/maintainers/mariusbalcytis)

---

Top Contributors

[![mariusbalcytis](https://avatars.githubusercontent.com/u/1590072?v=4)](https://github.com/mariusbalcytis "mariusbalcytis (8 commits)")

---

Tags

mailemailmailer

### Embed Badge

![Health badge](/badges/maba-mail-renderer-bundle/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M430](/packages/easycorp-easyadmin-bundle)[shopware/storefront

Storefront for Shopware

674.7M286](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M674](/packages/shopware-core)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

16164.9k1](/packages/symfony-ux-toolkit)[chameleon-system/chameleon-base

The Chameleon System core.

1029.4k6](/packages/chameleon-system-chameleon-base)[heimrichhannot/contao-pwa-bundle

A bundle to provide progressive web app support for contao.

101.2k](/packages/heimrichhannot-contao-pwa-bundle)

PHPackages © 2026

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