mjml2html - Generate HTML Email Body with MJML
Generates a HTML email body from a MJML template
The function mjml2html generates an HTML email body from a MJML template. It requires a string input in the form of a MJML template, and the output is the corresponding HTML email body. The function also has an optional parameter called validationLevel, which specifies the level of validation to be performed on the MJML template before rendering. The possible values for this parameter are skip, soft, and strict. The function is part of the MJML library, which was created to simplify the process of coding responsive email designs. The library abstracts the complexity of responsive HTML and automatically generates it, making it easy to build responsive emails with tags such as mj-section and mj-column. With MJML, users can write high-level code through extensible and reusable components, and build their own custom components as well.
You can also embed images by generating a base64 image based on using the function files/asset2base64
Examples
Input:
Output: Corresponding HTML email body.
Input:
Output: Corresponding HTML email body with image.
Input:
Output: Corresponding HTML email body with button.
Note: The MJML library used in this function can be found at https://mjml.io. Use the template editor to create your templates.
mjml
<mjml><mj-body><mj-section><mj-column><mj-text>Hello World!</mj-text></mj-column></mj-section></mj-body></mjml>
validationLevel
skip