PHPackages                             trt/swift-css-inliner-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. trt/swift-css-inliner-bundle

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

trt/swift-css-inliner-bundle
============================

A Swiftmailer plugin that provide css inline feature

v0.4(10y ago)1131.5k4MITPHPPHP &gt;=5.3.3

Since Dec 19Pushed 10y ago2 watchersCompare

[ Source](https://github.com/toretto460/swift-css-inliner-bundle)[ Packagist](https://packagist.org/packages/trt/swift-css-inliner-bundle)[ RSS](/packages/trt-swift-css-inliner-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (5)Used By (0)

swift-css-inliner-bundle
========================

[](#swift-css-inliner-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/ba48cee9e4d1da079d7ccb1a2d6bdc2734f62fd54f32dcea2c5093fb060528c9/68747470733a2f2f706f7365722e707567782e6f72672f7472742f73776966742d6373732d696e6c696e65722d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/trt/swift-css-inliner-bundle)[![Build Status](https://camo.githubusercontent.com/4e38aab25968c3f7bba7a7a4e38473f83815285e70e1eb53ed1430b81feb47e8/68747470733a2f2f7472617669732d63692e6f72672f746f726574746f3436302f73776966742d6373732d696e6c696e65722d62756e646c652e706e67)](https://travis-ci.org/toretto460/swift-css-inliner-bundle)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/96984d5cb13088d2507730c8c8f6409e085b9dcb8045dfa5eedd5e6911cdf8e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746f726574746f3436302f73776966742d6373732d696e6c696e65722d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f733d37653561303566623933343663313434336338323335656361353337366262663331353533623364)](https://scrutinizer-ci.com/g/toretto460/swift-css-inliner-bundle/)[![Total Downloads](https://camo.githubusercontent.com/a1428786e59757893aecf1ebd1c08042728440c99978ffe58154d21344ea53a0/68747470733a2f2f706f7365722e707567782e6f72672f7472742f73776966742d6373732d696e6c696e65722d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/trt/swift-css-inliner-bundle)

When HTML emails are viewed in browser-based email apps (like YahooMail!, Gmail, Hotmail, etc), those applications strip out the HEAD and BODY tags by default, so the only way to style the content is to place inline the CSS within the style attribute. This is a dirty work for frontenders. This plugin provides exactly the CSS processing to fille the style attributes.

Ex. using the [Zurb ink](http://zurb.com/ink/) mail template [![Before After Plugin](https://camo.githubusercontent.com/55ec0abd7bdb7c06b0c76adee2ba7faaa8e13c3da4019b1fcf01311f91e0b7a9/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f34393533363333352f6265666f72652d61667465722e706e67)](https://dl.dropboxusercontent.com/u/49536335/before-after.png)

\#1. Installation

\####Add the dependency within the `composer.json`

```
    "require": {
        "trt/swift-css-inliner-bundle": "~0.3"
    }
```

run `php composer.phar install`

\####Enable the bundle (add the following line within the AppKernel.php)

```
$bundles = array(
    [...]
    new \Trt\SwiftCssInlinerBundle\TrtSwiftCssInlinerBundle(),
);
```

\#2. Usage - Full Example

```
/**
 * @Route("/hello/{name}", name="_demo_hello")
 */
public function helloAction($name)
{
    $message = \Swift_Message::newInstance()
        ->setSubject('Hello Email')
        ->setFrom('send@example.com')
        ->setTo('recipient@example.com')
        ->setContentType('text/html')
        ->setBody(".text{ color: red; } $name ")
    ;
    $message->getHeaders()->addTextHeader(
        CssInlinerPlugin::CSS_HEADER_KEY_AUTODETECT
    );

    $this->get('mailer')->send($message);
}
```

\#3. Usage - Step-by-step example

\####1. Create the swiftmailer message.

```
$message = \Swift_Message::newInstance()
    ->setSubject('Hello Email')
    ->setFrom('send@example.com')
    ->setTo('recipient@example.com')
    ->setContentType('text/html')
    ->setBody('.text{color:red;}   Hello ')
;
```

\####2. AutoDetect the "style" Html tag

The auto detect mode will find css within the style tag

```
$message->getHeaders()->addTextHeader(
    CssInlinerPlugin::CSS_HEADER_KEY_AUTODETECT
);
```

#### Add your style explicit

[](#add-your-style-explicit)

**ATTENTION**

The explicit mode work only with the php IMAP extension installed @see

```
$message->getHeaders()->addTextHeader(
    CssInlinerPlugin::CSS_HEADER_KEY, //The key that say to the plugin "Apply this CSS"
    ".text{ color: red; }"
);
```

#### Send the message.

[](#send-the-message)

```
$this->get('mailer')->send($message);
```

\#4. Configuration options

No configuration is necessary.

It is possible to customize the behaviour of the [CssToInlineStyles](https://github.com/tijsverkoyen/CssToInlineStyles) class. This shows the default options:

```
# app/config/config.yml
trt_swift_css_inliner:
    inliner_class: TijsVerkoyen\CssToInlineStyles\CssToInlineStyles
    cleanup: false
    strip_original_style_tags: false
    exclude_media_queries: true
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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 ~211 days

Total

4

Last Release

3944d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97e5b23c6d1b7bd92d3ab1b3219515ab17cb504562b76e8694be6238470b87c1?d=identicon)[toretto460](/maintainers/toretto460)

---

Top Contributors

[![simodima](https://avatars.githubusercontent.com/u/1193857?v=4)](https://github.com/simodima "simodima (32 commits)")[![liuggio](https://avatars.githubusercontent.com/u/530406?v=4)](https://github.com/liuggio "liuggio (2 commits)")[![c960657](https://avatars.githubusercontent.com/u/111346?v=4)](https://github.com/c960657 "c960657 (1 commits)")[![yethee](https://avatars.githubusercontent.com/u/559488?v=4)](https://github.com/yethee "yethee (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trt-swift-css-inliner-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/trt-swift-css-inliner-bundle/health.svg)](https://phpackages.com/packages/trt-swift-css-inliner-bundle)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[illuminate/mail

The Illuminate Mail package.

5910.6M498](/packages/illuminate-mail)[fedeisas/laravel-mail-css-inliner

Inline the CSS of your HTML emails using Laravel

6084.8M3](/packages/fedeisas-laravel-mail-css-inliner)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

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