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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BetoAveiga created an issue. See original summary.

BetoAveiga’s picture

FileSize
1.12 KB
Matroskeen’s picture

Status: Active » Needs review
FileSize
1.76 KB
2.25 KB

Hello 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 the text is overriden later;
4) Removed the following line $message['plain'] = $message['body'];, because the text 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 via Html2Text() 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!

  • Matroskeen committed 1b0f4f3 on 8.x-1.x
    Issue #3177398 by Matroskeen, BetoAveiga: Plain text emails based on...
Matroskeen’s picture

Status: Needs review » Fixed

Alright, 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.