Passing variables from hook_mail to cutom twig template Custom twig template into hook_mail()

$body_content = array(
    '#theme' =&gt; 'mail_body_content',
    '#node' =&gt; $node,
);


I would like to access to node Entity and display value into the twig

myfield_name: {{ node.get('field_myfield_name').value }}


Render code

$renderedContent = \Drupal::service('renderer')-&gt;renderPlain($body_content);


Only myfield_name: is display.
How to get / pass the variable to twig ?
Rather than using node get to print a value just use this in twig.


  node.field_myfield_name.value


Otherwise preprocess your twig and get only required fields over sending complete node object to twig.

function theme_name_preprocess_mail_body_content(&amp;$variables) {
  $variables['myfield_name'] = $variables['node']-&gt;field_myfield_name-&gt;value; //$variables['node'] will be render $node from your hook_mail() function.
}


And in Twig myfield_name will work