The attached patch does the following:

  1. Adds rudimentary libraries support so that Emogrifier code can be maintained separately from htmlmail module code.
  2. Somewhat improves the documentation in the README file to mention the Emogrifier support.
  3. Adds the contents of site CSS files to the internal stylesheet, before the custom htmlmail css.

With this patch, finally my newsletters look the same in email as they do on the web!

CommentFileSizeAuthor
#38 modules_htmlmail.patch39.64 KBpillarsdotnet
#38 htmlmail.zip14.92 KBpillarsdotnet
#40 modules_htmlmail.patch43.46 KBpillarsdotnet
#40 htmlmail.zip16.62 KBpillarsdotnet
#39 modules_htmlmail.patch39.74 KBpillarsdotnet
#39 htmlmail.zip14.94 KBpillarsdotnet
#37 modules_htmlmail.patch33.55 KBpillarsdotnet
#37 htmlmail.zip14.3 KBpillarsdotnet
#36 modules_htmlmail.patch33.35 KBpillarsdotnet
#36 htmlmail.zip14.22 KBpillarsdotnet
#35 modules_htmlmail.patch32.73 KBpillarsdotnet
#35 htmlmail.zip14.01 KBpillarsdotnet
#34 modules_htmlmail.patch16.54 KBpillarsdotnet
#34 htmlmail.zip13 KBpillarsdotnet
#32 htmlmail_test_send.png97.44 KBpillarsdotnet
#32 htmlmail_test_received.png104.03 KBpillarsdotnet
#32 htmlmail_test_unstyled.png85.1 KBpillarsdotnet
#33 htmlmail_test_unstyled.png102.04 KBpillarsdotnet
#31 Screen shot 2011-03-06 at 4.39.24 PM.png33.29 KBlloydpearsoniv
#29 modules_htmlmail.patch16.42 KBpillarsdotnet
#29 htmlmail.zip13.21 KBpillarsdotnet
#25 modules_htmlmail.patch16.42 KBpillarsdotnet
#25 htmlmail.zip12.96 KBpillarsdotnet
#24 modules_htmlmail.patch16.34 KBpillarsdotnet
#24 htmlmail.zip12.95 KBpillarsdotnet
#22 modules_htmlmail.patch16.32 KBpillarsdotnet
#22 htmlmail.zip12.94 KBpillarsdotnet
#18 modules_htmlmail.patch16.21 KBpillarsdotnet
#18 htmlmail.zip12.94 KBpillarsdotnet
#16 modules_htmlmail.patch16.19 KBpillarsdotnet
#16 htmlmail.zip12.94 KBpillarsdotnet
#13 modules_htmlmail.patch16.15 KBpillarsdotnet
#13 htmlmail.zip12.93 KBpillarsdotnet
#11 modules_htmlmail.patch16.11 KBpillarsdotnet
#10 modules_htmlmail.patch15.41 KBpillarsdotnet
#9 modules_htmlmail.patch10.85 KBpillarsdotnet
#7 modules_htmlmail.patch10.81 KBpillarsdotnet
#6 modules_htmlmail.patch10.81 KBpillarsdotnet
#4 modules_htmlmail.patch8.46 KBpillarsdotnet
#3 htmlmail.patch8.47 KBpillarsdotnet
#1 htmlmail.patch8.39 KBpillarsdotnet
htmlmail.use-site-theme.patch4.98 KBpillarsdotnet
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pillarsdotnet’s picture

FileSize
8.39 KB
jason.fisher’s picture

love it. Will give this a shot on a project next week.

How is ths technique for Outlook/Hotmail/Yahoo/etc?

pillarsdotnet’s picture

FileSize
8.47 KB

Updated patch fixes typo in transliteration support.

@jason.fisher -- Works fine in Hotmail, Yahoo, iPhone (with transliteration), and Andrioid. Also works fine in GMail and Thunderbird. Haven't tested Outlook but I don't expect problems.

pillarsdotnet’s picture

FileSize
8.46 KB

Rerolled patch after the Great Git Migration.

Combines #1017776: Add transliteration support

lloydpearsoniv’s picture

PHP Fatal error: Call to undefined function libraries_get_path() in /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/htmlmail.module on line 222

pillarsdotnet’s picture

FileSize
10.81 KB

Okay; rewrote so that libraries support is merely recommended, not required.

EDIT: Ignore this patch -- it has a typo.

pillarsdotnet’s picture

FileSize
10.81 KB

Trying again...

lloydpearsoniv’s picture

Notice: Undefined variable: path in _htmlmail_emogrify() (line 228 of /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/htmlmail.module).

i had change the path manually before trying your update to see if i can get it working.
I followed all of the instructions but my emails do not show my theme. I thought maybe it was because i was using a subtheme, so i tried the basetheme & that didnt work either. Is there something else to this process that i am missiing?

pillarsdotnet’s picture

FileSize
10.85 KB

You're probably not missing anything; I just made a typo again. Edit your htmlmail.module and on line 228 change $path to $emogrifier_path.

Fixing...

Once you do get it straight, check your admin/reports/status page -- it should tell whether the Emogrifier code was found. Then visit admin/config/system/htmlmail/settings and check the following boxes:

  • Use site CSS
  • Emogrifier
  • Transliteration

I should probably make it so that the "Use site CSS" also checks "Emogrifier", and so that both options are disabled if Emogrifier is not available.

pillarsdotnet’s picture

FileSize
15.41 KB

Improved and lightly tested. Patch looks bigger because the _htmlmail_emogrify() function was moved to an include file, but overall code size is actually reduced as compared with the last patch.

pillarsdotnet’s picture

FileSize
16.11 KB

Better status report text.

lloydpearsoniv’s picture

PHP Fatal error: Call to undefined function _htmlmail_emogrifier() in /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/htmlmail.install on line 60,

Thats after trying the latest patch

pillarsdotnet’s picture

FileSize
12.93 KB
16.15 KB

weird... Maybe I can't use module_load_include() in an install hook?

(testing...)

Weird. Works for me...

Either drupal_get_path() is not available or you are missing the include file created by the last patch.

Try this one. If it doesn't work, check to make sure that that emogrifier/emogrifier.inc exists within the htmlmail module directory.

Attaching both a patch and a zipped copy of the patched module.

lloydpearsoniv’s picture

i replaced my directory with the one in the zip file...and this is what i got.
Warning: implode(): Invalid arguments passed in htmlmail_requirements() (line 67 of /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/htmlmail.install).

lloydpearsoniv’s picture

maybe the issue could be related to the fact that i am running PHP 5.3

pillarsdotnet’s picture

FileSize
12.94 KB
16.19 KB

I'm running PHP 5.3.6

Try this one.

lloydpearsoniv’s picture

Warning: Missing argument 1 for _htmlmail_emogrifier(), called in /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/htmlmail.admin.inc on line 28 and defined in _htmlmail_emogrifier() (line 60 of /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/emogrifier/emogrifier.inc).

pillarsdotnet’s picture

FileSize
12.94 KB
16.21 KB

bah.

lloydpearsoniv’s picture

right back to this error again.

PHP Fatal error: Call to undefined function _htmlmail_emogrifier() in /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/htmlmail.admin.inc on line 28

pillarsdotnet’s picture

I honestly don't see how that error is possible. The include line immediately precedes the error you are reporting. Is it possible that PHP is running out of memory?

lloydpearsoniv’s picture

I have my PHP memory set to 512M in both apache2 & cli php.ini on a server with 7.5GB of memory. PHP is not running out of memory.
I removed my old htmlmail folder from the server & replaced with the on from the zip file, restarted apache to make sure apc isn't interfering & this is what i got.

I am actually getting 500 errors when using your version of the module & i have to look at the server logs just to find out whats wrong.

pillarsdotnet’s picture

FileSize
12.94 KB
16.32 KB

This should avoid the 500 errors but shouldn't work any differently. Somehow the module_load_include() line isn't working for you. Check permissions on the files and directories created by the patch?

lloydpearsoniv’s picture

here is the new error that i am getting
Warning: array_flip(): Can only flip STRING and INTEGER values! in _htmlmail_emogrifier() (line 69 of /var/aegir/platforms/prod1/drupal-7.0/sites/all/modules/htmlmail/emogrifier/emogrifier.inc).

pillarsdotnet’s picture

FileSize
12.95 KB
16.34 KB

Again, I can't imagine where that error is coming from. The only possible value of $paths in the code I submitted is NULL or an empty array.

(hmm...)

Well, in one place I assume that an uninitialized variable is empty(). I suppose that's a bad assumption, but in PHP it's *supposed* to be true.

Nevertheless, removing the assumption:

pillarsdotnet’s picture

FileSize
12.96 KB
16.42 KB

Looking again, I suppose it was converting NULL to array(0=>NULL) which would explain the problem.

Fixed?

lloydpearsoniv’s picture

I am getting a 500 error on chrome & a whitescreen on firefox when trying to sends a test email. I cant find any visible errors anywhere at the moment.

pillarsdotnet’s picture

Okay, I can duplicate that. I'm having no problems sending newsletters, but I'm getting the same error on a test message.

(troubleshooting...)

Errors the same way on simplenews "send test" and htmlmail "send test"... Curiouser and curiouser...

lloydpearsoniv’s picture

Thats how i was getting a majority of my errors, via attempting to send a test message. I should have stated that earlier

pillarsdotnet’s picture

FileSize
13.21 KB
16.42 KB

Okay, fixed, I think. At least, test messages now send on *my* site...

(another stupid typo, btw -- "emogrifer" --> "emogrifier")

lloydpearsoniv’s picture

SUCCESS!!!
Now i have to figure out why my theme isn't going through the email

lloydpearsoniv’s picture

My emails look like the attachment yet my site looks like this http://pearsoncommunications.com
Any idea on how to fix this?

pillarsdotnet’s picture

Screenshots attached:

htmlmail_test_send.png
The admin/config/htmlmail/test screen I'm using.
htmlmail_test_received.png
What it looks like in Thunderbird with "Use site CSS" and "Emogrifier" turned on.
htmlmail_test_unstyled.png
What it looks like in a browser with no CSS at all.

So... compose something with html that would get styled by your theme CSS and test. Of course, it would be nice if the htmlmail test page would allow filter selection and wysiwyg editors like the node editing page, but that's a matter for another patch.

If you're still having problems,
Make sure that on admin/config/system/htmlmail you have the following (and only the following) checked:
  • Use site CSS
  • Emogrifier
  • Transliteration
Visit admin/reports/status and make sure that "Emogrifer class" is "Available".
Compare "View Source" on your received email with "View Source" on your website pages.
pillarsdotnet’s picture

FileSize
102.04 KB
htmlmail_test_unstyled.png
What it looks like in Thunderbird with "Use site CSS" and "Emogrifier" turned off.
pillarsdotnet’s picture

FileSize
13 KB
16.54 KB

Modified so that it only grabs styles with "media=all" or "media=screen" and ignores the rest.

pillarsdotnet’s picture

Title: Use site theme css in HTML emails. » Allow using drupal themes to format HTML emails.
FileSize
14.01 KB
32.73 KB

Heavily modified and lightly tested.

  • Allows selecting a drupal theme to format emails. This really lets your emails look just like a webpage. You can even create a special theme just for emails.
  • Finishes the stub implementation of MailSystemInterface as described in Creating HTML formatted emails in Drupal 7.
  • Allows full control over the mail_system variable: generates a select list of MailSystemInterface implementations for each installed module.
  • Adds pathologic support for converting urls from relative (node/100) to absolute (http://example.com/node/100) format, so that linked resources are available to email recipients.
pillarsdotnet’s picture

FileSize
14.22 KB
33.35 KB

Discovered that having a blank value for $mail_system[$module] produces a run-time error. Re-coded to prevent that from happening.

pillarsdotnet’s picture

FileSize
14.3 KB
33.55 KB

Minor improvements:

  • Strip Javascript, as it doesn't work properly in email clients, and may contribute to a false-positive spam classification.
  • Corrected error in regex matching inline stylesheets.
  • Removed redundant 'title' key from the hook_menu entry
pillarsdotnet’s picture

FileSize
14.92 KB
39.64 KB

More improvements:

  • Delegated most of the filtering to filter.module where it belongs.
  • Enable WYSIWYG editing in the template and test email forms.
  • Create a "Plaintext emails only" profile field for users who prefer plaintext-only emails.
  • Sends non-plaintext mails as multipart/alternative with both text-only and html parts.

Cleanup:

  • For consistency replaced all "e-mail" with "email".
  • Replaced "Implementation of" with "Implements" in comments.

Todo:

  • Move emogrifier and transliteration to their own filter modules.
  • Move UI for controlling variable_set('mail_system') to its own module.

EDIT: This patch relies on drupal_html_to_text which is currently broken by Patch #356074. A fix is posted in the same thread.

pillarsdotnet’s picture

FileSize
14.94 KB
39.74 KB

Fixed bug that was preventing the "Plaintext emails only" profile field from saving.

pillarsdotnet’s picture

FileSize
16.62 KB
43.46 KB

Created "Mail System" module for displaying the administrative UI for setting the mail_system variable.

Todo: Add AJAX to the form so a new module can be added without reloading the page.

pillarsdotnet’s picture

Okay, split this whole thing off to a sandbox module:

http://drupal.org/sandbox/pillarsdotnet/1088646

Note that the title says "Theme Mail" and the instructions say "theme_mail" but really it's just a fork of HTMLMail.

pillarsdotnet’s picture

Status: Needs review » Fixed

Ah; nevermind. I see I now have commit access.

Committed to 7.x-1.x branch.

Status: Fixed » Closed (fixed)

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