IGonics / laravel-mail-css-inliner by ggordon

Laravel 5 Mail CSS Inliner Service
3
1
2
Package Data
Maintainer Username: ggordon
Maintainer Contact: ggordon@igonics.com (ggordon)
Package Create Date: 2016-06-25
Package Last Update: 2017-05-15
Language: PHP
License: MIT
Last Refreshed: 2024-11-17 03:01:13
Package Statistics
Total Downloads: 3
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel 5 Mail CSS Inliner

Why?

Most email clients won't render CSS (on a <link> or a <style>). The solution is to inline your CSS directly into the HTML. Doing this by hand is tedious and difficult to maintain. The goal of this package is to automate the process of inlining that CSS before sending the emails.

How?

Using a wonderful CSS inliner package wraped in a SwiftMailer plugin and served as a Service Provider. It works without configuration

Transforming:

<html>
    <head>
        <style>
            h1 {
                font-size: 24px;
                color: #000;
            }
        </style>
    </head>
    <body>
        <h1>Your content</h1>
    </body>
</html>

Into this:

<html>
    <head>
    </head>
    <body>
        <h1 style="font-size: 24px; color: #000;">Your content</h1>
    </body>
</html>

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require igonics/laravel-mail-css-inliner.

This package requires Laravel 5.x

{
  "require": {
        "igonics/laravel-mail-css-inliner": "~1.0"
    }
}

Next, update Composer from the Terminal:

$ composer update

Once this operation completes, you must add the service provider. Open app/config/app.php, and add a new item to the providers array.

'IGonics\LaravelMailCssInliner\LaravelMailCssInlinerServiceProvider',

Found a bug?

Please, let me know! Send a pull request or a patch. Questions? Ask! I will respond to all filed issues.

Inspiration

This package was greatly inspired by Emogrifier CSS Inliner and Fede Isas's implementation of a similar service provider. The implementation became less configurable however with its main dependency CssToInlineStyles becoming less configurable with it's latest update which presented breaking changes to the existing API. This package was created as a more configurable solution with the ability to also handle poorly formatted HTML, which the previous implementations had issues with.

License

This package is open-sourced software licensed under the MIT license