If you configure a rule with a HTML body to a fixed value in the rules ui everything works fine. But if you populate the body field via a parameter all HTML tags are stripped away.

Define a body parameter which displays a form before the rule is executed. With vbo for example.

screenshot_rules_paramter.png

Than you can use the formated text value as a parameter but all the HTML tags are stripped away.

screenshot_rules_html_action-1.png

We need to set sanitize to TRUE to avoid this.

In mimemail.rules.inc

        'body' => array(
          'type' => 'text',
          'label' => t('Body'),
          'description' => t("The mail's message HTML body."),
          'sanitize' => TRUE,
        ),

Comments

marcusx’s picture

Status: Active » Needs review
StatusFileSize
new420 bytes

Here is a patch for this...

sgabe’s picture

adam_b’s picture

Yes, this appears to fix my problem in #1814098: Email sent by Rules doesn't use MimeMail settings - many thanks :)

rahulshah_1988’s picture

Hi,

Since I am new to the drupal I am not sure how to add the patch. Can I just add the line in the file 'mimemail.rules.inc' ? My server is not local I log in to the admin and see the drupal files.

marcusx’s picture

@rahulshah_1988

Yes you can add the line manually to your file.

Off topic info:
With a one line change this is ok, but often there migth be more complicated changes and than it is much easier to use the patch. It is also a good practice to keep all the patches somewhere in your project so you can reapply them if there is an update to the module and the change hasn't gone in yet. And you always can check which changes you have done to contrib projects. This is extra important if you have more than a few patches.

You can read more about appling a patch here http://drupal.org/patch/apply and here http://drupal.org/node/1399218.

sgabe’s picture

Title: Rule Sent HTML Mail sanitizes the $body if populated by a parameter. » Rule sanitizes the $body if populated by a parameter
Status: Needs review » Fixed

Patch in #1 committed, thanks!

rahulshah_1988’s picture

I checked MIME MAIL. I think it works fine I have an option in the Action of rules module saying that 'Send HTML mail'. I suppose I have to manipulate $node to get the value in html format. If I print $node using php code it shows me an array of list values in which I can see my field buried in HTML format.

Now How do I access that value from $node? Any idea?

Status: Fixed » Closed (fixed)

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

mykola dolynskyi’s picture

Issue summary: View changes

Years passed and this problem still exists.
I have killed 3 days figuring out why markup I pass to event breakes to HTML special characters

Please, change it to FALSE or expose as option to RuleAction

Custom module solution:

function my_help_func_rules_action_info_alter(&$info) {
    if(!empty($info['mimemail'])) {
        $info['mimemail']['parameter']['body']['sanitize'] = false;
    }
}