PHPackages                             robertotru/to-inline-style-email-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. robertotru/to-inline-style-email-bundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

robertotru/to-inline-style-email-bundle
=======================================

A Symfony2 bundle for using the CssToInlineStyles translator by tijsverkoyen

1.5.2(8y ago)59384.3k↑86.4%34[1 PRs](https://github.com/robertotru/ToInlineStyleEmailBundle/pulls)MITPHPPHP &gt;=5.5

Since Jan 21Pushed 3y ago2 watchersCompare

[ Source](https://github.com/robertotru/ToInlineStyleEmailBundle)[ Packagist](https://packagist.org/packages/robertotru/to-inline-style-email-bundle)[ Docs](http://github.com/gushphp/ToInlineStyleEmailBundle)[ RSS](/packages/robertotru-to-inline-style-email-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (7)Used By (0)

ToInlineStyleEmailBundle
========================

[](#toinlinestyleemailbundle)

**ToInlineStyleEmailBundle** is a *Symfony2* bundle to use the **CssToInlineStyles** translator by *Tijs Verkoyen* (see  for the repository)

Requirements
============

[](#requirements)

**ToInlineStyleEmailBundle** is only supported on **PHP 5.5** and up.

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

[](#installation)

Please, use the *Composer* to install this bundle in your Symfony2 app.

The following lines should be added in your `composer.json`

```
"require": {
    "gushphp/to-inline-style-email-bundle": "~1.4.0"
},
```

Then, register the bundle in your AppKernel by adding the following line:

```
    new RobertoTru\ToInlineStyleEmailBundle\RobertoTruToInlineStyleEmailBundle(),
```

Documentation and Examples
==========================

[](#documentation-and-examples)

The bundle provides a service named **css\_to\_inline\_email\_converter**. Use it in a controller to have a nice shortcut to the converter developed by *Tijs Verkoyen*. E.g.:

```
public function indexAction() {
    $converter = $this->get('css_to_inline_email_converter');
    ...
}
```

Get the HTML and the CSS as a string and set this required values to the converter object, e.g.

```
$converter = $this->get('css_to_inline_email_converter');

$html = ...; // get the HTML here
$css = ....; // get the CSS here

return $converter->inlineCSS($html, $css);
```

The retrieval of the HTML and CSS files from its folder it is only up-to you. E.g. in your controller retrieve the content of your CSS as:

```
file_get_contents($this->container->getParameter('kernel.root_dir').'/../src/Acme/TestBundle/Resources/css/mystyle.css');
```

Of course, it is supposed that a Symfony user will use a template instead of a static HTML page. Hence, for convenience, the service provides a function capable to render a template. E.g.:

```
$converter->setHTMLByView(
    'AcmeTestBundle:MyController:my_template.html.twig',
    [
        'param_1' => $val_of_param_1,
        // ...,
        'param_n' => $val_of_param_n
    ]
);
```

The preceding function must be used *in vece* of function `setHTML()`.

To use the `generateStyledHTML` method just use it like:

```
$converter->setHtml($html);
$converter->setCss($css);
return $converter->generateStyledHTML();
```

You can use inline css directly in Twig template:

```
{% inlinecss '/css/email.css' %}

...

{% endinlinecss %}
```

Paths relative to bundle are supported as well:

```
{% inlinecss '@AppBundle/Resources/css/email.css' %}

...

{% endinlinecss %}
```

Dynamic variable is supported (Use absolute path with variable with asset or directly with full path to file)

```
{% set path = asset('css/email.css', null, true) %}
{% inlinecss path %}

...

{% endinlinecss %}
```

Dynamic variable is supported (Use absolute path with variable with asset or directly with full path to file)

```
{% set path = asset('css/email.css', null, true) %}
{% inlinecss path %}

...

{% endinlinecss %}
```

Read the docs in the files for further details on the usage of the service.

Contributing
============

[](#contributing)

**ToInlineStyleEmailBundle** is an open source project, under MIT license. Contributions are encouraged. Feel free to contribute to improve this bundle.

About the author of the bundle
==============================

[](#about-the-author-of-the-bundle)

**ToInlineStyleEmailBundle** has been originally developed by Roberto Trunfio. Currently, the bundle is mantained by Luis Cordova via the gushphp organization.

The initial package on packagist robertotru was moved here to gushphp organization with the author consent for maintenance.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~56 days

Total

6

Last Release

3046d ago

PHP version history (2 changes)1.2PHP &gt;=5.3.3

1.4.0PHP &gt;=5.5

### Community

Maintainers

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

---

Top Contributors

[![robertotru](https://avatars.githubusercontent.com/u/2987914?v=4)](https://github.com/robertotru "robertotru (29 commits)")[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (27 commits)")[![mente](https://avatars.githubusercontent.com/u/391997?v=4)](https://github.com/mente "mente (10 commits)")[![Richtermeister](https://avatars.githubusercontent.com/u/624921?v=4)](https://github.com/Richtermeister "Richtermeister (8 commits)")[![kalypso63](https://avatars.githubusercontent.com/u/1765257?v=4)](https://github.com/kalypso63 "kalypso63 (6 commits)")[![paulandrieux](https://avatars.githubusercontent.com/u/1942078?v=4)](https://github.com/paulandrieux "paulandrieux (1 commits)")[![khasinski](https://avatars.githubusercontent.com/u/702380?v=4)](https://github.com/khasinski "khasinski (1 commits)")[![crussell52](https://avatars.githubusercontent.com/u/375294?v=4)](https://github.com/crussell52 "crussell52 (1 commits)")[![fernandops26](https://avatars.githubusercontent.com/u/11939055?v=4)](https://github.com/fernandops26 "fernandops26 (1 commits)")[![alsar](https://avatars.githubusercontent.com/u/1380676?v=4)](https://github.com/alsar "alsar (1 commits)")[![OsoianMarcel](https://avatars.githubusercontent.com/u/12122711?v=4)](https://github.com/OsoianMarcel "OsoianMarcel (1 commits)")

---

Tags

symfonybundlecssstyleemailinline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robertotru-to-inline-style-email-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/robertotru-to-inline-style-email-bundle/health.svg)](https://phpackages.com/packages/robertotru-to-inline-style-email-bundle)
```

###  Alternatives

[gushphp/to-inline-style-email-bundle

A Symfony2 bundle for using the CssToInlineStyles translator by tijsverkoyen

59311.5k](/packages/gushphp-to-inline-style-email-bundle)[inlinestyle/inlinestyle

Apply CSS stylesheets directly as inline styles to a HTML document

140635.8k8](/packages/inlinestyle-inlinestyle)[voku/css-to-inline-styles

Only a Fork of -&gt; CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

20252.5k2](/packages/voku-css-to-inline-styles)

PHPackages © 2026

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