承接 yarri/mjml 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yarri/mjml

Composer 安装命令:

composer require yarri/mjml

包简介

PHP implementation of the MJML email templating language

README 文档

README

Tests

PHP implementation of the MJML email templating language. Converts MJML markup into responsive HTML emails — without Node.js at runtime.

Requirements

  • PHP 7.1+

Installation

composer require yarri/mjml

Usage

$mjml = '
    <mjml>
        <mj-head>
            <mj-title>Hello World</mj-title>
            <mj-preview>Check this out!</mj-preview>
        </mj-head>
        <mj-body>
            <mj-section>
                <mj-column>
                    <mj-text font-size="20px" color="#333333">Hello World</mj-text>
                    <mj-button href="https://example.com">Click here</mj-button>
                </mj-column>
            </mj-section>
        </mj-body>
    </mjml>
';

$html = Yarri\Mjml::Mjml2Html($mjml);

Supported components

Head

Component Description
mj-title Sets the <title> of the email
mj-preview Adds a preview text (hidden preheader)
mj-font Imports a web font (only if used in font-family)
mj-breakpoint Sets the responsive breakpoint width (default: 480px)
mj-style Injects custom CSS into the <head>
mj-attributes Sets default attribute values for components (mj-all applies to all)
mj-html-attributes Injects custom HTML attributes into rendered elements by CSS class selector

Body

Component Description
mj-body Root body element
mj-section A horizontal section; supports background color, image, full-width
mj-column Column inside a section; supports border, padding, background
mj-wrapper Wraps sections; useful for shared backgrounds
mj-group Groups columns for Outlook compatibility
mj-hero Full-width hero with background image
mj-text A block of text
mj-image An image
mj-button A call-to-action button
mj-divider A horizontal rule
mj-spacer Vertical whitespace
mj-table An HTML table
mj-raw Raw HTML passthrough (not processed)
mj-social A row of social media icons
mj-social-element A single social media link
mj-navbar A responsive navigation bar
mj-navbar-link A link inside a navbar
mj-accordion A collapsible accordion
mj-accordion-element A single accordion item
mj-accordion-title Title of an accordion item
mj-accordion-text Body of an accordion item
mj-carousel An image carousel
mj-carousel-image A single image in a carousel

Testing

The test suite compares output against the reference Node.js MJML 4.18.0 implementation. Install Node.js dependencies first:

nvm use
npm install

Then run the tests:

./vendor/bin/run_unit_tests test/

Run a single test case:

./vendor/bin/run_unit_tests test/tc_mj_column.php

统计信息

  • 总下载量: 498
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固