Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comments
Comment #1
ygerasimov CreditAttribution: ygerasimov commentedAttached patch introduces new variable 'registration_keep_html_mail_format'.
Comment #2
mgiffordI 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']:
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.
Comment #3
mgiffordComment #4
flocondetoileDrupal 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 ?
Comment #5
flocondetoileneeds review
Comment #6
CountPacMan CreditAttribution: CountPacMan at ThinkShout commentedThis looks likes a security issue. Please let me know if I'm seeing this wrong and need to review it further.
Comment #7
Greg BoggsYou'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_...
Comment #8
toamit CreditAttribution: toamit commentedYes, 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.
Comment #9
alez.k CreditAttribution: alez.k as a volunteer commentedI'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?
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedAny idea whether this is yet slated to be in a dev or full release?
Comment #11
khakistocracy CreditAttribution: khakistocracy commentedJust 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?
Comment #12
oschuetze CreditAttribution: oschuetze commentedHi,
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
Comment #13
olivier.bouwman CreditAttribution: olivier.bouwman at ThinkShout commentedHere 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.
Comment #14
Chris Matthews CreditAttribution: Chris Matthews commentedThe 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.
Comment #15
olivier.bouwman CreditAttribution: olivier.bouwman at ThinkShout commentedUpdated patch #13 to work with 7.x-1.7 (changed registration_update_7108 -> registration_update_7109)
Comment #16
omnia.ibrahim CreditAttribution: omnia.ibrahim commentedWhen 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?
Comment #17
omnia.ibrahim CreditAttribution: omnia.ibrahim commentedWe 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'] : '',
Comment #18
olivier.bouwman CreditAttribution: olivier.bouwman at ThinkShout commentedHi omnia.ibrahim, see if this updated patch helps.
Comment #19
omnia.ibrahim CreditAttribution: omnia.ibrahim commentedHi Olivier, Thanks but I think we also need the default_value to be changed
Comment #20
markusd1984 CreditAttribution: markusd1984 commentedI 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
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?
Comment #21
gcbPatch 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).
Comment #22
markusd1984 CreditAttribution: markusd1984 commentedsweet thanks, got it to work by adding in manually the field in the db, since I didn't wanted to re-install the module. :)
Comment #23
goose2000 CreditAttribution: goose2000 commentedDoes 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.
Comment #24
randal60 CreditAttribution: randal60 commentedAny movement on this? Just want to send HTML reminder emails and not break anything else.