PHPackages                             seacommerce/twig-swift-css-inliner - 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. seacommerce/twig-swift-css-inliner

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

seacommerce/twig-swift-css-inliner
==================================

Create inlined html e-mails using your favorite template and mailer tool.

v1.0.2(7y ago)0542MITPHP

Since Jul 24Pushed 7y ago2 watchersCompare

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

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

twig-swift-css-inliner
======================

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

Create inlined html e-mails using your favorite template and mailer tool.

**Features:**

- Render e-mail templates using twig;
- Provide css though the same twig template;
- Provide any additional css from a file to load any base styles, for example;
- Optionally also provide a text/plain fallback body.

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

[](#installation)

Using composer

`composer require Seacommerce/twig-swift-css-inliner`

Examples
--------

[](#examples)

Steps

1. Create a twig template for your e-mail body using the `html` block.
2. Optionally provide a subject using the `subject` block.
3. Optionally provide a text/plain body using the `text` block.
4. Provide CSS using the `styles` block.
5. Provide any additional CSS from a string or a file.
6. "Compile" the message.
7. Send it.

example.html.twig:

```
{% block subject %}
    Order confirmation #{{ orderNbr }}
{% endblock subject %}

{% block styles %}

        p {
            font-size: 16px;
        }

{% endblock styles %}

{% block html %}

    Dear {{ name }},
    Thank you for your order.

            Order #
            {{ orderNbr }}

            Order date
            {{ orderDate|date('Y-m-d') }}

            Reference
            {{ reference }}

        Kind regards,
        Inliners-R-us

{% endblock html %}

{% block text %}
    Dear {{ name }},

    Thank you for your order.

    Order number: {{ orderNbr }}
    Order date: {{ orderDate|date('Y-m-d') }}
    Reference: {{ refference }}
{% endblock text %}
```

example.css

```
body {
    background-color: aliceblue;
    padding: 10px;
    margin: 0;
}

table{
    width: 100%;
}

td, th {
    border: solid 1px #000;
}

th {
    text-align: left;
}

p {
    padding: 0;
    margin-bottom: 10px;
}

p.greeting {
    font-size: smaller;
    text-align: center;
}
```

example.php

```
require_once('vendor/autoload.php');

use Seacommerce\TwigSwiftCssInliner\CssInliner;
use Twig_Environment;
use Twig_Loader_Filesystem;

$loader = new Twig_Loader_Filesystem('/Path/to/templates/folder');
$twig = new Twig_Environment($loader);
$inliner = new CssInliner($twig);
$additionalCssFile = '/path/to/additional.css';

$viewData = [
    'name' => 'Sil',
    'orderNbr' => 223423,
    'reference' => 'ABC12',
    'orderDate' => new \DateTime('2013-09-28', new \DateTimeZone('utc')),
];
$message = $inliner->createEmailFromTemplateFile('example.html.twig', $viewData, $additionalCssFile);

// send the message...
```

Output message

```
Message-ID:
Date: Sat, 28 Sep 2013 00:00:00 +0000
Subject: Order confirmation #223423
From:
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=__test_phpunit_aWSqkye88HQhRMbg

--__test_phpunit_aWSqkye88HQhRMbg
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

    Dear Sil,

    Thank you for your order.

    Order number: 223=
423
    Order date: 2013-09-28
    Reference:=20

--__test_phpunit_aWSqkye88HQhRMbg
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

    Dear Sil,

Thank you for your order.
=

            Order #
            223423

        =

            =
Order date
            2013-09=
-28

            Reference
            ABC12

  =

        Kind regards,
        Inl=
iners-R-us

--__test_phpunit_aWSqkye88HQhRMbg--
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

Total

3

Last Release

2828d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4d90ccd4014bf6aa16df793f5ee717f65dbd58d382706bfaf6d3d3aae7fb707?d=identicon)[sil](/maintainers/sil)

![](https://www.gravatar.com/avatar/43b7005270313b3780605dc247170adc4c109f15652723d5066e703f1b9464b2?d=identicon)[nielssteenbakker](/maintainers/nielssteenbakker)

---

Top Contributors

[![smoelker](https://avatars.githubusercontent.com/u/5102879?v=4)](https://github.com/smoelker "smoelker (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[dachcom-digital/emailizr

Pimcore Emailizr - create html emails the right way!

17370.2k4](/packages/dachcom-digital-emailizr)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)[sproutcms/cms

Enterprise content management and framework

241.6k4](/packages/sproutcms-cms)

PHPackages © 2026

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