I want to render twig when sending email (if it is possible) or include a template.
My code is like so:
/**
* Implements hook_mail().
*/
function reg_email_mail($key, &$message, $params) {
$options = array(
'langcode' => $message['langcode'],
);
switch ($key) {
case 'new_user':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('User created: @title', array('@title' => $params['title']), $options);
$message['body'][] = \Drupal\Core\Mail\MailFormatHelper::htmlToText($params['message']);
break;
}
}
I'd like to change $params['message']
or part of this with twig. Is it possible?