It seems Swift Mailer has stopped working with Webform after "Allow email handler theme to be customized" was added.
With the following config set, emails that are sent from Webform always are blank when viewing the email:
Default Mail System: Formatter and Sender both set to "Swift Mailer".
Webform -> Edit Email notification handler: "Send email as HTML" is checked. "Theme to render this email" can be set to "Default" or the actual active theme name, both result in a blank email.
When the email is sent out, this appears in the error log: "Theme hook not found."
If I change the following config, the emails are no longer blank, but obviously are not using Swift Mailer:
Default Mail System: Formatter and Sender both set to "Default PHP mailer".
Webform + Swift Mailer was properly working with Webform dev-5.x 22b30e1. Not sure if this specific added feature broke support or something else in the latest updates.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2998239-19.patch | 27.87 KB | jrockowitz |
| #15 | 2998239-15.patch | 27.67 KB | jrockowitz |
| #15 | interdiff-2998239-13-15.txt | 3.07 KB | jrockowitz |
| #13 | 2998239-13.patch | 24.37 KB | jrockowitz |
| #11 | 2998239-11.patch | 20.33 KB | jrockowitz |
Comments
Comment #2
jrockowitz commentedThe attached patch includes comments that describe the two issues/changes which caused unexpected regressions.
Comment #3
jrockowitz commented#2998248: Create dedicate HTML template for HTML email addresses webform HTML emails being wrapped twice in an HTML template
Comment #4
cbildstein commentedAwesome, thanks for the quick turn around.
Confirmed patch now has Webform emails displaying correctly with Swift Mailer.
Comment #6
jrockowitz commentedComment #7
jrockowitz commentedSince this regression results in data loss, I tagged a new release.
Comment #8
weseze commentedThis is still an issue for any mailhandler that extends on swiftmailer...
I have a custom mailhandler built on top of swiftmailer and it still breaks.
Comment #9
jrockowitz commentedTo prevent the conflicts with Swift Mailer, I think we should change the 'theme' setting to be called 'theme_name'.
Comment #11
jrockowitz commentedComment #13
jrockowitz commentedComment #15
jrockowitz commentedSomething is off with my patch's exported webform config. I am hoping this one is better.
Comment #16
weseze commentedThe patch works. Setting to RTBC.
But I am still wondering why we need special processing for Swiftmailer?
Should webform really be interfering with the things Swiftmailer (or any mail handler for that matter) does?
Or is it actually Swiftmailer that is not handling its $message['body'] properly?
Comment #17
jrockowitz commentedI noticed that Swift Mailer wraps the email message in
<html> and <body>tags. My code prevents messages from being wrapped twice. It is probably unneeded.I took the approach that site builders could define
<html> and <body>tags in the email message template which would be respected by the Webform's Mail senderComment #18
bygeoffthompson commentedjrockowitz, weseze, and cbildstein,
Thanks for the work here. This (#15) has resolved my issue with empty email body text on my Drupal site (8.6.1) with Webform (rc21) that uses Swift Mailer (via SMTP). My email_handler's default message text now includes the submission values as expected.
Cheers
Comment #19
jrockowitz commentedAttached patch removes the code mentioned in #16.
Comment #20
weseze commentedPatch #19 works perfect!
The last remaining piece is still needed:
It's a shame we can't do without, but I think that would be a Swiftmailer issue, nothing webform can do about that... (also the reason why I work with an extended class that detects HTML markup and does this "Markup-switch-trick")
Comment #21
weseze commentedComment #22
berdirThat Swiftmailer requires a Markup object is a (security) feature, not a bug. And it shouldn't hurt to always do that *if* you think that the input is safe.
Wondering a bit about this feature in general. Seems a bit overkill to be able to configure that separately for each webform and it overlaps with the setting of the mailsystem module. I'd be happy to help push that setting into core.
PS: Changes like this tend to be painful for distributions and modules that provide webform default configuration, because renaming/changing keys breaks them, the update function only helps with existing sites. So we (distribution maintainers) appreciate if you only those kind of configuration changes when really necessary :)
Comment #23
jrockowitz commented@Berdir It is rare I have to change a property name but it felt like the 'theme' property which becomes a mail param was going to conflict with more than just Swift Mailer.
I agree that it…
The catch22 here is people may need to control how the webform's email message is themed and it is rendered with the EmailWebformHandler.
We could define a global default webform email theme name settings. I am not sure how many people are going to be using this feature.
Comment #24
jrockowitz commented@Berdir For exported config (in distributions), I am really hoped that I could find a hook or event that could be used to update webform related config as it is being imported, sync'd, updated, etc...
@see #2996455: Make sure imported webform config is up-to-date
Comment #26
jrockowitz commentedEveryone, thank you for your patience and feedback. I committed the latest patch.
Setting up a global default webform email theme name setting should be handled in a new ticket.
Comment #28
guardian87 commentedCould you provide some additional information about this one?
Has the problem been resolved now or not?
I am using the latest (5.2) version of webform, and from what I can see that patch #19 is included there.
However, in combination with Swiftmailer, HTML emails from webform is still broken and gives me a "theme hook not found" in the logs.
Am I missing something?
For now I am sending the webform submissions as plain text, which is a shame.
Many thanks.
Comment #29
jrockowitz commented@guardian87 You probably need to create a new issue.
You might also want to post a general question about Webform and SwiftMailer support to https://drupal.stackexchange.com/questions/tagged/webforms
Comment #30
guardian87 commentedhuh?
Now why would I want to do that?
The issue that I am seeing is literally what is described in this issue.
There is a patch that claims to have fixed it, yet I am using the latest version of the webform module.
So this issue is the perfect place to report this imho.
Also there is this in #26
Is this being addressed currently, as I don't see an issue in the queue for this? (or did I overlook?)
I am merely asking for clarification as I am still seeing this exact issue.
Many thanks again.
Comment #31
rang501 commentedThere is a bug somewhere because I'm seeing a similar issue - Swiftmailer theme hook is missing and HTML emails have a blank body. If I clear the cache, it works for some time.
This isn't probably Webform issue, probably Swiftmailer or Drupal core itself.
Comment #32
cola commented@guardian87 any progress with your issue? we have the same, html is empty if you send it over swiftmailer.