Symfony Mailer Twig Context in Subject Line

371 views Asked by At

I am using Symfony 5 and the mailer component with twig templating. The context works fine for the body of the email, but is there not a way to apply that to the email subject line also?

Right now I'm having to manually do my own string replace, which I just can't believe this isn't possible within the same message context.

1

There are 1 answers

0
yivi On BEST ANSWER

The subject of the email is not a Twig template, so it won't interpolate any variables from the template context.

You'll need to do your own interpolation when creating the actual email message and setting an email subject.