Pimcore Emailizr - create html emails the right way!

Installs: 313 129

Dependents: 4

Suggesters: 0

Security: 0

Stars: 17

Watchers: 12

Forks: 6

Open Issues: 1

Type:pimcore-bundle

v3.1.0 2024-04-30 08:54 UTC

README

Join the chat at https://gitter.im/pimcore/pimcore Software License Latest Release Tests PhpStan

Requirements

  • Pimcore: ^11.0
  • PHP: >= 8.1
  • Twig >= 3.9

Release Plan

Installation

"require" : {
    "dachcom-digital/emailizr" : "~3.1.0",
}

Add Bundle to bundles.php:

return [
    EmailizrBundle\EmailizrBundle::class => ['all' => true],
];
  • Create valid email markup with inky and inline styles.
  • Respect editables in pimcore edit mode.

Usage

Just extend the emailizr layout:

{% extends '@Emailizr/layout.html.twig' %}

This will include a markup like this. You may want to change it:

{% apply spaceless %}
{{ emailizr_style_collector.add('@EmailizrBundle/public/css/foundation-for-emails/foundation.min.css') }}
{% emailizr_inline_style %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width"/>
    {% block headStyles %}
        <style type="text/css">
            {% autoescape false %}
                {{ emailizr_inline_style(emailizr_style_collector) }}
            {% endautoescape %}
        </style>
    {% endblock %}
</head>
{% apply inky_to_html %}
    <body>
        {% block body %}
            <table class="body">
                <tr>
                    <td class="center" align="center" valign="top">
                        <center>
                            {% block content %}
                            {% endblock %}
                        </center>
                    </td>
                </tr>
            </table>
            <!-- prevent Gmail on iOS font size manipulation -->
            <div style="display:none; white-space:nowrap; font:15px courier; line-height:0;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
        {% endblock %}
        </body>
{% endapply %}
</html>
{% end_emailizr_inline_style %}
{% endapply %}

Service

If you need to parse values in a custom context, you may use the ContentService.

<?php

use EmailizrBundle\Service\ContentService;

class YourClass
{
    protected ContentService $contentService;

    public function __construct(ContentService $contentService)
    {
        $this->contentService = $contentService;
    }

    public function parse($content)
    {
        $cssFile = PIMCORE_WEB_ROOT . '/static/css/email.css';

        return $this->contentService->checkContent($content, $cssFile, FALSE, TRUE, TRUE);
    }
}

Further Information

Upgrade Info

Before updating, please check our upgrade notes!

License

DACHCOM.DIGITAL AG, Löwenhofstrasse 15, 9424 Rheineck, Schweiz
dachcom.com, dcdi@dachcom.ch
Copyright © 2024 DACHCOM.DIGITAL. All rights reserved.

For licensing details please visit LICENSE.md