Problem/Motivation
When you go to the settings of a webform and add an email handler you can choose if the email needs to be sent as HTML or not.
In our particular case, we need this option to disable the multipart formatting for the emails and send only the plain/text format, instead of sending also an HTML version of the email.
Steps to reproduce
- Add an email handler for a webform
- Uncheck "Send email as HTML" on the handler Advanced settings.
- Submit the webform and receive an HTML email or Multipart message.
Proposed resolution
- Consider $message['params']['html'] to remove all HTML formatting and only sent plain/text emails.
- Remove default Mailgun text formatter on emails if $message['params']['html'] is FALSE.
Remaining tasks
- At UI level, on the appropriate labels (MailGun default format & "Send email as HTML" webform handler option), this should be reflected.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3177398-2_3-interdiff.txt | 2.25 KB | Matroskeen |
#3 | 3177398-3.patch | 1.76 KB | Matroskeen |
| |||
#2 | issue-3177398.patch | 1.12 KB | BetoAveiga |
Comments
Comment #2
BetoAveigaComment #3
MatroskeenHello and thanks for the patch :)
After manual review and some tests with Mailgun test form, I'd like to apply some corrections.
Here is a patch with the following changes:
1) Slightly changed comments and made sure they match coding standards;
2) Moved
$message['params']['html']
check after text format processing; I'd like to keep it that way to make sure there is no any dangerous markup inside;3) Removed useless line
'text' => Html::escape($message['body']),
, because thetext
is overriden later;4) Removed the following line
$message['plain'] = $message['body'];
, because thetext
variable will be assigned later - it can be either$message['plain']
if plain version was provided together with email, or the plain version will be created viaHtml2Text()
converter.5) Passed "width" parameter to Html2Text() constructor, because by default there is a limit of 70 characters per line (which might be not obvious);
Looking forward to your review,
Thanks!
Comment #5
MatroskeenAlright, hopefully, it's good enough to be committed and to be included in the stable release :)
Feel free to re-open if there is anything to fix/improve.
Thanks!