When html is used in outgoing emails it got stripped (replaced with text using drupal_html_to_text() function in hook_mail implementation).

It would be nice feature to be able to allow HTML in emails.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ygerasimov’s picture

Status: Active » Needs review
FileSize
2.08 KB

Attached patch introduces new variable 'registration_keep_html_mail_format'.

mgifford’s picture

I haven't tested this, but it looks like the patch doesn't introduce this variable at all.

It seems mostly about just freeing up the ['#format']:

-    $form['scheduling']['open']['#format'] = 'Y-m-d H:i:s O';
+    $form['scheduling']['open']['#date_format'] = 'Y-m-d H:i:s O';

Anyways, this is probably obvious for folks more familiar with this module.

EDIT: Yup, looks like you uploaded this patch #2160649: Date popup expects #date_format instead of #format property by mistake.

mgifford’s picture

Status: Needs review » Needs work
flocondetoile’s picture

Version: 7.x-1.x-dev » 7.x-1.3
Status: Needs work » Active
FileSize
442 bytes

Drupal send by default email in pain text. This little patch permit to send HTML mail with others modules like MimeMail or HTMLMail. What's your mind about security as the message body isn't sanitized ?

flocondetoile’s picture

Status: Active » Needs review

needs review

CountPacMan’s picture

Status: Needs review » Postponed (maintainer needs more info)

This looks likes a security issue. Please let me know if I'm seeing this wrong and need to review it further.

Greg Boggs’s picture

Status: Postponed (maintainer needs more info) » Needs work

You're correct. Allowing admin screens to publish unfiltered content is against the Drupal security policy. To fix this, the ideal solution is to implement input formats on the field so that the site builder can choose the input format.

However, I believe passing the content through filter_xss is enough to prevent the security issue.

https://api.drupal.org/api/drupal/includes%21common.inc/function/filter_...

toamit’s picture

Yes, allowing format selection is very good idea and much required feature.

In my setup even the line breaks are getting stripped and html messages are stripped of formatting.

alez.k’s picture

I've written some code in my module to be able to use all the filters in message body without hack the original code.
Can you warn me if I've forgotten some security feature?

function mymodule_form_alter(&$form, &$form_state, $form_id) {  
  if($form_id == "registration_registrations_broadcast_form") {
    $form['message']['#type'] = 'text_format';
    $form['message']['#base_type'] = 'textarea';
    $form['message']['#format'] = 'filtered_html';
  }

function mymodule_mail_alter(&$message) {
  if ($message['id'] == 'registration_broadcast') {
    $format = $message['params']['message']['format'];
    $value = $message['params']['message']['value'];
    // to avoid the the conversion of lines break of default plain_text filter
    if ($format === 'plain_text') {
      $message['body'] = drupal_html_to_text($value);
    } else {
      $message['body'] = check_markup($value, $format);
    }
  }
}
Anonymous’s picture

Any idea whether this is yet slated to be in a dev or full release?

khakistocracy’s picture

Just curious if anybody can help out with this? The custom module in #9 is almost there, although it's not playing well with a check for tokens on submit.

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan()

I can't figure out how to pass the HTML as a string to token_scan(). Any advice?

oschuetze’s picture

Hi,

any news to this issue?
I'm not a drupal developer, but what about using other modules like Mime Mail and/or Mail System? Would that help to use the mail functionality? In "Mime Mail", a text filter can be defined.

Regards,
Oliver

olivier.bouwman’s picture

Status: Needs work » Needs review
FileSize
3.32 KB

Here is a different patch that does the following:
- Changes the reminder template field so you can choose the text format.
- Adds a field for the reminder template text format to the registration_entity table.
- Sets an html header in registration_mail if html is found in the email.

Chris Matthews’s picture

Version: 7.x-1.3 » 7.x-1.x-dev

The patch in #13 applied cleanly to includes/registration.forms.inc; registration.install and registration.module on 7.x-1.x-dev and after reviewing/testing it seems like a great solution, but I'm leaving the status as Needs review so that someone else can put their eyes on this before changing the status to RTBC.

olivier.bouwman’s picture

Updated patch #13 to work with 7.x-1.7 (changed registration_update_7108 -> registration_update_7109)

omnia.ibrahim’s picture

When I applied the patch and saved the field, when I go again, the textarea is empty. Its not retrieved from the default_value. Any help?

omnia.ibrahim’s picture

We should use the following the form.inc:

'#default_value' => isset($settings['reminder_template']['value']) ? $settings['reminder_template']['value'] : '',
'#format' => isset($settings['reminder_template']['format']) ? $settings['reminder_template']['format'] : '',

olivier.bouwman’s picture

Hi omnia.ibrahim, see if this updated patch helps.

omnia.ibrahim’s picture

Hi Olivier, Thanks but I think we also need the default_value to be changed

markusd1984’s picture

I tried #15 & #18 but unfortunataly it doesn't work with Registration v 7.x-1.6+24-dev

In Registrations > Settings, even when I have enabled a reminder and date, time and body text entered I can't save it anymore and get the below error message

If sending a reminder, provide a date and template.

When I go to Email Registrants to send a test email, I now get the option to select a text format ie. HTML or plain but regardless which i use once I put some plain text or simple html ie. a href , while I receive the email it's empty except for the word "Array" in the body email.

Any help please?

gcb’s picture

Patch in #18 has a misformatted schema in the .install file. It uses "size" for the text field where it should use "length" (as it does in the hook_update).

markusd1984’s picture

sweet thanks, got it to work by adding in manually the field in the db, since I didn't wanted to re-install the module. :)

goose2000’s picture

Does this affect/include 'reminder' emails too ? Their format too, is unusable text, 0 formatting. Thanks for guidance.

Answer:

Yes, was able to cleanly apply #21 and run DB updates normally from /admin interface. It does send HTML email for both the "Email Registrants" tab and from the Settings -> Reminder email.

It made WYSIWYG interface for reminder email settings fields, but was not available for the "Email Registrants" tab - just text.

Also noticed these tokens do not work / render from these forms (different issue, I know):
[registration:original] - empty. Normally prints the title of the registration entity (works from RULES)
[node:title] - nothing rendered for either forms.

randal60’s picture

Any movement on this? Just want to send HTML reminder emails and not break anything else.