Closed (fixed)
Project:
Workbench Email
Version:
2.3.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Aug 2022 at 21:33 UTC
Updated:
14 Sep 2022 at 03:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
larowlanThere's a patch here, can you review and report back? https://www.drupal.org/files/issues/2022-08-08/3219682-n1.patch
#3219682: Add support for HTML emails is related (the patch is from there)
Over there someone else reported the same issue as you
Comment #3
larowlanhttps://git.drupalcode.org/project/workbench_email/-/merge_requests/12/d... is where we map html to text/html - can you debug that and see if your site isn't running that?
Comment #4
larowlanCan you check the format key of your templates is set to HTML?
Comment #5
shelaneYes, it was set to HTML. Without yet applying the patch, just switching to plain text restores functionality. It will be a while before I can push a patch out, especially having a working version of plain text.
Comment #6
larowlanHmm, that sounds like you have some other module interfering then
Do you have any other modules that implement hook_mail_alter or similar?
Comment #7
shelaneThe email modules I have are swiftmailer and mailsystem.
Comment #8
mrshowermanIt looks like Swiftmailer is setting the wrong Content-type header, due to a parameter which is passed since Workbench Email 2.3.0.
In WorkbenchEmailProcessor, the format is passed to the
$paramsarray:It contains either
text_plainorhtml, but Swiftmailer seems to expect a mime type instead. In \Drupal\swiftmailer\Plugin\Mail\SwiftMailer::getContentType(), we have this:Here, the
$message['params']['format']contains the stringhtml, which is taken for the Content-type header.Not sure if this is a bug of SwiftMailer or the new functionality in Workbench Email, but we can work around this by additionally passing a real content type to
$this->mailManager->mail(). Attaching a first patch.Comment #9
mrshowermanComment #10
mrshowermanReducing the change footprint in the patch so it can be applied together with #3017273: Recipient Type Email Field does not work for translated content, always uses original language value..
Comment #11
larowlanAh, so if the issue is that 'format' collides with a key used by Swiftmailer, how about we name it something else in $params?
E.g. template_format or similar?
Comment #12
larowlanComment #13
mrshowermanI'm not sure what the purpose of adding the format to the $params array in #3219682: Add support for HTML emails was, but in order not to break even more, I thought it was a better idea to add the
content_typekey additionally, which I knew would be caught by Swiftmailer in favor offormat.Comment #14
larowlanThis should do the trick, and is much smaller patch
Comment #15
shelaneIf you change a config element, you might want to include an update hook.
Comment #16
larowlanI'm not changing a config element. I'm just changing what we pass to hook_mail - another reason why this option is a lighter touch
Comment #17
mrshowermanNice!
I wasn't aware that the
formatparameter was only by coincidence named equally to what SwiftMailer expects, and that its only purpose was to be handled in hook_mail.RTBC+1.
Comment #18
larowlanNice, I'll wrap this up and release it tomorrow (evening here now)
Comment #20
larowlanTagging 2.3.1 - thanks