1. Go to this page and download the library: Download notfloran/mjml-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
notfloran / mjml-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new NotFloran\MjmlBundle\MjmlBundle(),
];
// ...
}
// ...
}
public function sendEmail(MailerInterface $mailer)
{
// The MJMl body is rendered by the mjml tag in the twig file
$htmlBody = $this->renderView('templates/mail/example.mjml.twig', ['name' => 'Floran']);
$email = (new Email())
->from('[email protected]')
->to('[email protected]')
->subject('Hello from MJML!')
->html($htmlBody);
$mailer->send($email);
// ...
}
use NotFloran\MjmlBundle\Renderer\RendererInterface;
// ...
public function sendEmail(MailerInterface $mailer, RendererInterface $mjml)
{
$mjmlBody = $this->renderView('templates/mail/example.mjml.twig', ['name' => 'Floran']);
$htmlBody = $mjml->render($mjmlBody);
$email = (new Email())
->from('[email protected]')
->to('[email protected]')
->subject('Hello from MJML!')
->html($htmlBody);
$mailer->send($email);
// ...
}