Problem/Motivation
Environment:
Drupal : 9.3.0
Patches Applied To Drupal:
https://www.drupal.org/project/drupal/issues/3180227#comment-13890098
PHP : 8
dBug for Drupal : 2.0.0
Business Rules : 2.0.0-beta1
Patches Applied to Business Rules:
https://www.drupal.org/project/business_rules/issues/3250592
https://www.drupal.org/project/business_rules/issues/2998984#comment-131...
https://www.drupal.org/project/business_rules/issues/3067571#comment-135...
https://www.drupal.org/project/business_rules/issues/3056302#comment-134...
Symfony Mailer : 1.x-dev
Patches Applied to Symfony Mailer:
https://www.drupal.org/project/symfony_mailer/issues/3256190
With Drupal Swift Mailer library no longer being maintained we have decided to move over to the Symfony mailer. Everything else works great with symfony mailer, except the Drupal Business Rules. We are able to send emails in HTML format, but the only problem is that none of the tokens we insert works.
Business Rules
Create Action: Send email
Use site mail as sender: Yes
To: {{current_user->mail}}
Subject: Ticket #[node:nid]
Mail format: HTML
Symfony Mailer:
Add Policy: Business Rules
SUB-TYPE: All
Add Element: Body
When the body element is added in symfony mailer the email is sent out, the user will receive the HTML formatted email, but tokens wont be replaced. When you don't add the body element in Symfony mailer, the user will receive the email, but not in HTML format and tokens will be replaced.
Steps to reproduce
Set up environment as above and test between adding and removing a body element formatted with a HTML email with Tokens in the policy created.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | symfony_mailer.system-token.3258789-6.patch | 1.05 KB | adamps |
| #3 | 3258789-3-system-emails-missing-tokens.patch | 1.15 KB | alex.ksis |
Comments
Comment #2
adamps commentedThanks for the report. I believe the problem is that
system_mail()replaces tokens butSystemEmailBuilder::preRender()does not. The same would happen whenever an email action is used in any module.The fix is to use
TokenProcessorTrait, similar toUserEmailBuilder.I will be busy myself for a month or more - patches are welcome.
Comment #3
alex.ksis commentedJust adding the trait seems to be working fine.
Comment #4
loze commentedPatch in #3 works for me, thank you.
Comment #5
adamps commentedGreat thanks @alex.ksis and @loze.
Please can you undo the unrelated change to code alignment? The existing alignment is used consistently throughout this module and I prefer it. If we are going to change it (which I would like to debate before deciding) then let's do it properly throughout the code, in another issue.
Comment #6
adamps commentedComment #8
adamps commented