Currently, pm_email_notify passes the message body through drupal_html_to_text() before sending it as an email.

I understand why we wouldn't want to trust html in normal private messages (created by users through their browser).

However, some private messages might be created internally by custom code (such as during a custom cron job). Email notifications for these private messages should allow the html from the message body to pass through to the email.

The code change is simple. (see patch file)

After the change, you can do the following:

privatemsg_new_thread( , , , array('pm_email_notify_send_as_html' => TRUE))
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

codeglyph’s picture

Status: Active » Needs review
FileSize
904 bytes

Good job. But i think that isn't enough. The transformation
trim(check_markup($message['body'], $message['format'], FALSE)) that is applied to the body if the send_as_html flag is present will still clean all the html tags.

Check the manual here: http://api.drupal.org/api/drupal/modules--filter--filter.module/function...

so i think performing only a 'trim' is the right way to do it.

Here's a patch based on yours that does that.

However i feel the running of the body through 2 functions (in the original version )is somewhat redundant.
'!pm_body' => trim(drupal_html_to_text(check_markup($message['body'], $message['format'], FALSE))), Since check_markup has the ability to purge or escape the html and the drupal_html_to_text (http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_html...) function should provide viable alternatives for tags. In this case there's nothing to provide for since the tags are already cleaned by the first function.

Status: Needs review » Needs work

The last submitted patch, pm_email_notify.module.patch, failed testing.

Berdir’s picture

Version: 6.x-1.3 »

You need to create the patch from the privatemsg main directory or the testbot can't apply your patch.

I'm not sure about the suggested solution but anyway, new features need to go into the 6.x-2.x branch.

codeglyph’s picture

Status: Needs work » Needs review
FileSize
1017 bytes

Here is the patch derived from 2x-dev.

Status: Needs review » Needs work

The last submitted patch, pm_email_notify.module.patch, failed testing.

te-brian’s picture

FileSize
3.87 KB

This is a brand new patch that allows other modules to alter the e-mail tokens.

This would indirectly solve the OP's issue because he could change the body to be whatever he wants.

It will also allow other modules to add whatever tokens they please.

If there is still a desire to have this html e-mail option, feel free to move this patch to a new issue dedicated to just the token alter.

Berdir’s picture

Same here, go testbot!

Interesting idea, I definitly like that more than the previous patch. Note that we are using real tokens in D7, I'm currently not sure if token replacements can be altered in D7 but the list certainly can be extended.

Berdir’s picture

Status: Needs work » Needs review
te-brian’s picture

Version: » 6.x-2.x-dev

Bump. Technically this patch does not directly address the OP's problem, but it provides a better facility for email token altering in general. If this were committed and we still desired a specific setting for html emails, it could be implemented via the alter.

Berdir’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Commited.

BenK’s picture

Subscribing to help test D7 port

ivnish’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)