PHPackages                             kachar/zend-mjml - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kachar/zend-mjml

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kachar/zend-mjml
================

MJML Client

1.0.0(9y ago)7301MITPHPPHP &gt;=5.4

Since Oct 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/kachar/zend-mjml)[ Packagist](https://packagist.org/packages/kachar/zend-mjml)[ Docs](https://github.com/kachar/zend-mjml)[ RSS](/packages/kachar-zend-mjml/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

ZF2 Module for MJML to HTML rendering
-------------------------------------

[](#zf2-module-for-mjml-to-html-rendering)

This module is based on: MJML The only open-source framework that makes responsive-email easy

 [ ![](https://cloud.githubusercontent.com/assets/6558790/12672296/7b66d8cc-c675-11e5-805d-c6d196320537.png) ](https://github.com/mjmlio/mjml)

With this module you can define your email templates as MJML files and render them using Zend `ViewModel`. The MJML markup will be sent to  in order to be transformed to HTML.

The package supports:

- simple variable replacement after the markup has been converted. (`*.mjml` files)
- complex templating system using PHP inside the mjml markup. (`*.pmjml` files)

You can send the complete emails using a pre-defined email transport method.

Requirements
------------

[](#requirements)

- PHP Version &gt;= 5.4
- [Zend Framework 2](https://github.com/zendframework/zf2) (2.\*)
- [Guzzle Http Client](https://github.com/guzzle/guzzle) (~5)
- [Guzzle Cache Subscriber](https://github.com/guzzle/cache-subscriber) (\*)

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

[](#installation)

1. Add `"kachar/zend-mjml": "dev-master"` to your `composer.json` file and run `php composer.phar update`.

    ```
    "require": {
        "kachar/zend-mjml": "dev-master"
    }
    ```

    ```
    $ php composer.phar update
    ```
2. Add `ZendMjml` to your `config/application.config.php` file under the `modules` key.

    ```
    'modules' => [
        'ZendMjml',
    ],
    ```

Configuration
-------------

[](#configuration)

Under the key `mjml` you can set the following options in the configuration:

`mjmlServiceUrl`: Sets the MJML endpoint (default `https://mjml.io`)

`timeout`: Float describing the timeout of the request in seconds. Use 0 to wait indefinitely (default value `10`).

`connectTimeout`: Float describing the number of seconds to wait while trying to connect to a server. Use 0 to wait indefinitely (default value `1.5`).

`transportAdapter`: The adapter that will be used to send the actual email. Two possible configurations:

- as a string - Any service that implements `Zend\Mail\Transport\TransportInterface` and can be fetched from ServiceLocator.

```
    'mjml' => [
        'transportAdapter' => [
            'type' => 'sendmail',
            'options' => [
                // see http://www.sendmail.org/~ca/email/man/sendmail.html
            ],
        ],
    ],
```

- as factory array - Configuration options based on `\Zend\Mail\Transport\Factory`. For advanced factory options you can see (official documentation)\[\].

```
    'mjml' => [
        'transportAdapter' => 'Zend\Mail\Transport\Sendmail',
    ],
    'service_manager' => [
        'invokables' => [
            'Zend\Mail\Transport\Sendmail' => 'Zend\Mail\Transport\Sendmail',
        ],
    ],
```

Usage
-----

[](#usage)

### Inline MJML makrup

[](#inline-mjml-makrup)

```
    $service = $this->getServiceLocator()->get('Service\Mjml');
    $mjml = '

          Hello {{ name }}

    ';

    // This is the final html to be sent to the recipients
    $body = $service->renderMjml($mjml);

    // You can replace simple variables inside the final output
    $body = $service->renderMjml($mjml, [
        'name' => 'direct example',
    ]);

    // Sending the email
    $email = $service->composeEmail($body);
    $email->setTo('email@example.com');
    $email->setSubject('Sample responsive MJML email');
    $service->sendEmail($email);
    // or
    echo $body;
```

### Using ViewModel that loads MJML makrup file

[](#using-viewmodel-that-loads-mjml-makrup-file)

```
    $service = $this->getServiceLocator()->get('Service\Mjml');

    $view = new ViewModel();
    $view->name = 'John Doe';
    $view->setTemplate('mjml/plain.mjml');
    // This is the final html to be sent to the recipients
    $body = $service->renderView($view);

    // Sending the email
    $email = $service->composeEmail($body);
    $email->setTo('email@example.com');
    $email->setSubject('Sample responsive MJML email using ViewModel');
    $service->sendEmail($email);
```

### Using ViewModel that loads PHP-MJML makrup file

[](#using-viewmodel-that-loads-php-mjml-makrup-file)

```
    $view = new ViewModel();
    // This will be replaced using str_replace in the final template
    $view->name = 'PHP MJML Template';

    // This will be replaced using php in the initial mjml template
    $view->products = [
        [
            'name' => 'Ham',
            'price' => '1.50',
            'quantity' => 5,
        ],
        [
            'name' => 'Cheese',
            'price' => '3.75',
            'quantity' => 3,
        ],
        [
            'name' => 'Bread',
            'price' => '5.00',
            'quantity' => 10,
        ],
    ];
    $view->setTemplate('mjml/php-mjml.pmjml');
    // This is the final html to be sent to the recipients
    $body = $service->renderView($view);

    // Sending the email
    $email = $service->composeEmail($body);
    $email->setTo('email@example.com');
    $email->setSubject('Sample responsive MJML email using PhpRenderer');
    $service->sendEmail($email);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3498d ago

### Community

### Embed Badge

![Health badge](/badges/kachar-zend-mjml/health.svg)

```
[![Health](https://phpackages.com/badges/kachar-zend-mjml/health.svg)](https://phpackages.com/packages/kachar-zend-mjml)
```

PHPackages © 2026

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