This project is not covered by Drupal’s security advisory policy.
Create responsive HTML emails with mjml.io.
Installation
Install the module with Composer in the usual way.
$ composer require drupal/mjml
Enable the module on the administration UI or with Drush.
Select and configure the MJML renderer
Binary render (default)
-
Configure the path of the NodeJS library in the settings.php:
<?php
$settings['mjml'] = [
'renderer' => [
'binary' => [
'options' => [
'path' => 'PATH_TO_THE_MJML_BINARY'
]
]
]
];
- Clear all cache in Drupal. (Ex.: Run
drush cr
)
API render
- Install juanmiguelbesada/mjml-php library with Composer.
$ composer require juanmiguelbesada/mjml-php
- Set your API credentials and change the default MJML renderer in the settings.php
<?php
$settings['mjml'] = [
'default_renderer' => 'mjml.renderer.api',
'renderer' => [
'api' => [
'client' => [
'application-id' => 'YOUR_APPLICATION_ID',
'secret-key' => 'YOUR_SECRET_KEY',
]
]
]
];
- Clear all cache in Drupal. (Ex.: Run
drush cr
)
(Optional) Send a test email
<?php
$params = [
'name' => 'YOUR_NAME',
];
$addressee = 'YOUR_EMAIL@ADDRESS.COM';
$mail_manager = \Drupal::service('plugin.manager.mail');
$template = \Drupal::moduleHandler()->moduleExists('swiftmailer') ? 'test_mail_mjml_twig_template_swiftmailer' : 'test_mail_mjml_twig_template';
$mail_manager->mail('mjml', $template, $addressee, \Drupal::service('language.default')->get()->getId(), $params);
Usage
Check the mjml.module file for examples how you can use this module with
- the default mail implementation in Drupal,
- the MailSystem module,
- or the SwiftMailer module.
RoadMap
The current implementation depends on the PHP integration provided by
notfloran/mjml-bundle Symfony bundle. This may change in the
future.
This project is managed and maintained on Github.
Supporting organizations:
Project information
- Seeking co-maintainer(s)
Maintainers are looking for help reviewing issues. - No further development
No longer developed by its maintainers. - Module categories: Integrations
- Ecosystem: Mail System
- 1 site reports using this module
- Created by mxr576 on , updated
- Drupal 10 is here!
No plans for now
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.