Variables set in hook_mailer_build_build() are left out in the BodyEmailAdjuster

Created on 15 April 2024, 12 months ago

Problem/Motivation

Hello! I tried to set some global variables for all the email builders we have. Its a user field, which i wanted to base it on the email address of the mail. The code on it self works and the variables are set correctly, but when testing the email - the twig variable was empty.

After some digging around i found that the Drupal\symfony_mailer\Plugin\EmailAdjuster::BodyEmailAdjuster has an `$email` variable, but the getVariables() do not have the variable set from the hook. Yet the hooks are fired before the adjuster.

Steps to reproduce

  1. Create a hook_mailer_PHASE function and set a variable $email->setVariable('foo', 'bar);
  2. Go to the test email and adjust the body, add `{{ foo }}` in the body
  3. Send the email - foo is an empty string -> this should be 'bar'
πŸ› Bug report
Status

Active

Version

1.4

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024