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

Created on 15 April 2024, 2 months ago
Updated 9 May 2024, about 2 months ago

Problem/Motivation

Hello! I tried to set some global variables for all the email builders we have. Its a user field i want to render in the mail, and the user object is based on the 'to' address. The code on it self works and the variables are set correctly, but when I was testing the email - the twig variable were not converted in the given string.

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.69.0 2024