Support Emogrifier
| Project: | HTML Mail |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | jrguitar21 |
| Status: | closed |
The problem -- Gmail and Outlook (two of the most used email clients) have very poor support for email standards, namely, they don't like external stylesheets and <style> tags.
The solution -- The emogrifier is used to modify HTML, applying a set of CSS rules directly to their tag components in the form of inline styles. The only thing you need to do, after applying the patch is download the emogrifier PHP source code (MIT License) and copy the emogrifier.php to the htmlmail module folder. This patch is built in such a way that it can be added to CVS without affecting functionality if the emogrifier is not present.
Note that the emogrifier support in this patch does not support external stylesheets using the <link> function, but it does support parsing of inline <style>. This idea comes from the simplenews template module, for which there is no real stable release for D6... so I decided to use this module in combination with the mail global header and footer I've found that I REALLY like this module!
Patch below...

#1
First patch against 6.x-1.x-dev
#2
Committed to 6.x.1.x-dev, please test
#3
#4
cool. I guess you decided you didn't need anyone to test... but if you just commited my patch then I can vouch that its working fine in a production environment.
#5
jrguitar21
It's causing some problems with ubercart and borks badly with some html -- i like it mostly but ill need to note that it's very experimental in the admin config.
May be short lived if it's too much hassle
Cheers.
#6
in particular DOMDocument does not like ubercart's invoices
#7
I've added the following around your code to combat the errors, seems everything works ok otherwise.
This is an awesome addition, don't know whether to enable it by default?
<?php// get and reset error levels so we dont get DOMDocument::loadHTML() errors
$errorlevel = error_reporting();
error_reporting(0);
$emogrifier = new Emogrifier($message['body'], $style);
$message['body'] = $emogrifier->emogrify();
error_reporting($errorlevel);
?>
#8
I found it very very useful.
Thanks a lot.
#9
Wow Drupal rocks in that kind of moments you read your planified issue and see patches :D
#10
I'm using this in HTML Email and I found a bug. It's converting my " " to and angel "A" character. I writing my html in Expression Web and then pasting. Is this something it doesn't support? Everything is fine when disabled, but I prefer to use it so I don't have to copy and past properties in all the tags.
#11
Too bad fckeditor doesnt have a built in emogrifier mode for making emails.
Im going to start testing this out, I think this functionality is a given and agree it should be standard in the module
...too bad the emogrifier is MIT & it cant be included in the module, no biggie though.
Is the ubercart invoice fix going in the dev too?
#12
Oh never mind that .. I see the emogrifier is already in the dev of the module. And looking around MIT is allowed in contribs. ...well thats nice!