Search by

Compile MJML to responsive HTML emails directly in PHP without requiring Node.js. Wraps the official MJML engine with Laravel and Symfony integration, including Twig support.

Package info

github.com/DefectiveCode/mjml

Type:laravel

pkg:composer/defectivecode/mjml

Statistics

Installs: 84 355

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 1

3.1.0 2026-11-20 17:40 UTC

README

Defective Code Logo

English | العربية | বাংলা | Bosanski | Deutsch | Español | Français | हिन्दी | Italiano | 日本語 | 한국어 | मराठी | Português | Русский | Kiswahili | தமிழ் | తెలుగు | Türkçe | اردو | Tiếng Việt | 中文

Introduction

MJML is a markup language specifically designed to simplify the process of coding responsive emails. Its semantic syntax ensures ease and simplicity, while its extensive library of standard components accelerates development and reduces the complexity of your email codebase. The open-source engine of MJML generates high-quality, responsive HTML that adheres to best practices. If you've experienced the frustrations of working with Outlook, this package is tailored for you.

Our MJML implementation serves as a wrapper for the official MJML API. It enables convenient compilation of MJML into HTML directly within PHP, without the need for NodeJS. This package is ideal for PHP applications that wish to incorporate MJML without the hassle of installing NodeJS and the MJML CLI.

It integrates with Laravel and Symfony, including a Twig filter and automatic rendering of .mjml.twig templates.

Example

// Without Laravel
(new MJML)->render(
    '<mjml><mj-body><mj-section><mj-column><mj-text>Hello World</mj-text></mj-column></mj-section></mj-body></mjml>'
);

// Minified HTML
(new MJML)->minify()->render(
    '<mjml><mj-body><mj-section><mj-column><mj-text>Hello World</mj-text></mj-column></mj-section></mj-body></mjml>'
);

// With Laravel
MJML::render(
    '<mjml><mj-body><mj-section><mj-column><mj-text>Hello World</mj-text></mj-column></mj-section></mj-body></mjml>'
);

// With Laravel and minified HTML
MJML::minify()->render(
    '<mjml><mj-body><mj-section><mj-column><mj-text>Hello World</mj-text></mj-column></mj-section></mj-body></mjml>'
);

Documentation

You may read the documentation on our website.

Development

Use PHP 8.5 or newer, Composer 2, and Bun 1.4.5. Install development dependencies with the discovery hook enabled:

composer install
test -f bun.lock
bun install --frozen-lockfile

Run the tests and quality checks:

composer validate --strict
composer test
composer test -- --order-by random
composer analyse -- --no-progress
composer lint -- --test
bun --bun run test
bun --bun run typecheck
bun --bun run format:check
bun --bun run package:check

Replay random test order with the reported seed by adding --random-order-seed <seed>. CI checks both lowest and stable Composer dependency resolutions on PHP 8.5 against Laravel 12 and 13, with randomized test order, and runs tests/Symfony against Symfony 7.4 and 8. The lowest resolution installs the oldest releases Composer accepts at or above the illuminate/support floors; Composer skips releases with security advisories, so it can run newer releases than those floors.

Use composer lint and bun --bun run format to apply formatting. Bun is pinned in package.json, and formatter scripts force the Bun runtime. Keep bun.lock tracked; composer.lock remains ignored for independent library dependency resolution.

The renderer lives in build/mjml.ts. build/build.sh is the release script, not a local compile helper: it prompts for a version and rewrites VERSION, builds every platform binary inside the oven/bun Docker image matching the Bun version pinned in package.json, signs and notarizes the macOS ARM64 binary, uploads the binaries to the download CDN, and then deletes the local build artifacts, including the binaries in bin/.

License

The MIT License (MIT). Please see License File for more information.