Inline CSS in HTML using Emogrifier.

0.3.2 2021-04-07 10:36 UTC

This package is auto-updated.

Last update: 2023-02-07 15:23:18 UTC


Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version

Inline CSS in HTML using Emogrifier.

Installation and requirements

Install via composer, using:

composer require saskoh/conaktiv-emogrifyplugin


  • PHP 5.6+
  • Emogrifier 3.x


By default, the plugin will inline CSS that is part of the HTML, eg. styles defined in <style> tags. You can instantiate the plugin with your own Emogrifier instance or change properties of the emogrifier instance. For a list of options, please head over to the Emogrifier documentation.

Please note, that the plugin is using one instance of Emogrifier to convert all message-parts, so the settings you make apply to all converted html parts.

Supplying custom CSS

$plugin = new EmogrifierPlugin();
$plugin->getEmogrifier()->setCss('.customStyle: { color: red; };');

Please note: Calling setHtml on the Emogrifier instance doesn't have an effect, since it will be replaced with the message body!


Here's how you could use the plugin to send emails with custom styles loaded from a file:

$emogrifier = new Pelago\Emogrifier(); $emogrifier->setCss(file_get_contents( /* path to your CSS file */ ));