Project:HTML Mail
Version:6.x-1.7
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

It would be great to have a form similar to the block visibility form that allows you to set which emails should be html and which should remain as plain text. This shouldn't be too difficult as each email has an id that consists of its module name and a key.

There should be two options:
* make all emails html except the following
* only make the following emails html

Also being about to match against patterns like you can with paths:
e.g. modulename_*

Comments

#1

sounds like a fair request, coding this efficiently is another story. Ideas welcome.

#2

Status:active» closed (fixed)

I've added this functionality to the latest 6.x dev
there are no patterns (for mail keys) only module name per line. This may produce weird results if the module name has an underscore (drupal 6 bug) but this problem will not exist in the d6 release.

I'm guessing filter/match by mail key would be an overkill.

Please test

#3

Actually, by mail key as well would be really helpful, as some specific mail key generated things might need to go plain text. Use Case: I've created a ticketing system where rules drives notifications, and how depending on the severity of the ticket. So, I've also patched rules to allow me to specify a particular mail key for some eMail messages it can send, so I can identify the ones that are going to my mobile phone directly, and then HTML Mail could recognise the mail key and not pass that particular eMail through the template.

So both would be good. :)

Could it not be done by simply changing the line

<?php
    $plain_match
= in_array(preg_replace('/_.*$/', '', $message['id']), $items);
?>

to
<?php
    $plain_match
= in_array(preg_replace('/_.*$/', '', $message['id']), $items) ||
                   
in_array($message['id'], $items);
?>

Shawn

#4

Status:closed (fixed)» active

I'm sorry to reopen the issue but i guess it would need some positive reviews before it can be really closed as fixed.

Did anyone succeed in excluding ubercart emails using this?
I've tried both the module name and email key.

Specifically, i'm trying to exclude processing of order emails, so i've used "uc_order" but it didn't work and i also read the warning about d6 bug when the module name contains underscores and that's the case.

So, i enabled debugging and the emal key shown was : uc_order_action-mail
I added this in a new line in the textarea but the emails are still being processed by html mail.
Thanks,
Da.

#5

Quite surprised...
I took a look at the module and it passes the $message['id'] to a preg_replace() function with a pattern like this '/_.*$/'
This means that with a key like "uc_order_action-mail" you get "uc".
Using this key finally skipped the uc_order emails from the htmlmail processing but it seems a pretty weak logic, but i'm not discovering anything new: i read what Chris Herberte wrote about this:

This may produce weird results if the module name has an underscore (drupal 6 bug) but this problem will not exist in the d6 release.

.
Thanks,
Da.

#6

Maybe instead of using the preg_replace function call, a simple foreach would be better...

<?php
    $plain_match
= FALSE;
    foreach (
$items as $item ) {
      if (
$message['id'] == $item || strpos($message['id'], $item) === 0 ) {
       
$plain_match = TRUE;
        break;
      }
    }
?>

While it's not as succinct as the one-line, it actually should do what is desired, no? This handles both cases of the entire mail key (so just the eMails with a specific mail key) as well as all eMails from a module (so the specified module name is found starting at position 0, the first character of the mail key).

Shawn

#7

Thank you!

Suggested change pushed to git; will roll a new release shortly.

#8

Version:6.x-1.x-dev» 6.x-1.7
Status:active» fixed

Fixed in 6.x-1.7 release.

#9

Wow! Talk about fast turn-around time! :D

#10

Status:fixed» closed (fixed)

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

nobody click here