There are a number of "This didn't work" tickets against this module in the queue.

I noticed that if I dispense with all of the regular expression stuff in _emogrifier_process() and just simply call through to the emogrifier library it just works.

So my question is, why is all that stuff there? The Emogrifier library seems perfectly capable of handling the full html and will scan the

elements itself to pick up the CSS? Patch to follow.

Comments

jamsilver’s picture

Title: Lots of bugs with emogrifier - it simple didn't work for me - why so complicated? » Lots of bugs - it simply didn't work for me - why so complicated?
Assigned: jamsilver » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.08 KB

This patch should certainly _just work_ for those trying to get this to work with HTMLMail.

roball’s picture

Title: Lots of bugs - it simply didn't work for me - why so complicated? » Remove all the complicated regexes and just let the Emogrifier library do the work
Version: 7.x-1.18 » 7.x-1.x-dev
Priority: Normal » Critical

Totally agreed. This also solves the critical bug #1336106: Emogrifier removes styles instead of embedding them!. I will post a patch for the D6 version later today.

roball’s picture

Title: Remove all the complicated regexes and just let the Emogrifier library do the work » Modify HTML code only by the Emogrifier library
Version: 7.x-1.x-dev » 6.x-1.x-dev
StatusFileSize
new10.74 KB

Attached is the patch against the 6.x-1.x branch. I can confirm this fixes #1336106: Emogrifier removes styles instead of embedding them!, in addition to many other potential problems, since most of the module's code has been removed. I have changed the target version of this issue to 6.x-1.x-dev since I have successfully tested it on the D6 version.

The D7 patch posted by jamsilver above needs work to additionally remove dead unneeded code.

roball’s picture

StatusFileSize
new10.74 KB

Patch attached again with its file name renamed, since the name in #3 above made problems in downloading through the browser.

bennybobw’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

@roball You should open separate issue to backport along with a link this so that people know there's a patch for 7.x on this thread.

roball’s picture

Status: Needs review » Needs work

OK, but the 7.x-1.x-dev patch from #1 needs work, as mentioned in #3.

dkelly60’s picture

I tried patching with this and get
Hunk #1 FAILED at 82.
1 out of 1 hunk FAILED

duaelfr’s picture

StatusFileSize
new10.63 KB

Patch rerolled against lastest 7.x-1.x-dev

duaelfr’s picture

Status: Needs work » Needs review

The previous patch was based on the #4 one

aidanlis’s picture

Patch #8 works ... without it half the content disappeared from my email. What the hell was the original module author thinking?

roball’s picture

Status: Needs review » Reviewed & tested by the community
deggertsen’s picture

Beautiful! Thanks for the patch @DuaelFr.

abudev’s picture

Patch applied and no inline styles applied.

PHP Document Object Model extension is available.
Module Libraries enabled.
Library emogrifier.php in sites/all/libraries/emogrifier

Is there something more?

restored the module and commented line 158 work for me but it's not the point

thsutton’s picture

The patch in #8 works great for me applied against 7.x-1.18.

john franklin’s picture

Patch in #4 works great for 6.x-1.18.

aquariumtap’s picture

Status: Reviewed & tested by the community » Needs work

I wouldn't recommend committing this yet. Currently any style definitions need to be within the text that is being filtered. That's not particularly handy.

Emogrifier is only passed the text that's being filtered. emogrifier.module, line 82:

$emogrifier = new Emogrifier($text, '');

That second parameter should contain the contents of any stylesheets used in the theme. At least that was my expectation after trying this module, but it's not documented where the styling should be.

thsutton’s picture

Why should it apply theme style sheets? There's no reason to expect theme stylesheets -- written to style whole pages, with lots of divs, classes and IDs -- will apply sensibly to filtered text.

The best use case for this module is in concert with modules like HTML Mail where it can be used to process whole emails *after* they've been themed and have their stylesheets.

I'd change it back to RTBC but find that a little rude when other people do it. :-)

aquariumtap’s picture

Status: Needs work » Reviewed & tested by the community

There's no module documentation about which stylesheets are used to convert classes to inline styles. That's really the core issue. I'll make a separate one for that.

This patch did work for me!

ollynevard’s picture

Patch in #8 worked for me against 7.x-1.18.

deggertsen’s picture

Issue summary: View changes

Can't wait for this to be committed. Frustrating to install this module on different sites only to have it work after realizing this patch hasn't been committed yet.

roball’s picture

In contrast to the Maintenance status that has been selected on this module's project page ("Actively maintained"), this module is obviously NOT maintained anymore. I don't suspect the maintainer will still care about it, so I wouldn't expect to see any commits unless a new maintainer takes over it.

marcus178’s picture

The latest 7.x-1.x-dev patch doesn't work for those with this issue

https://drupal.org/node/2195043

it needs to be

$emogrifier = new \Pelago\Emogrifier($text, '');

not

$emogrifier = new Emogrifier($text, '');

geek-merlin’s picture

Thanks @markus178 to link the issue #2195043: Install Issue - Not compatible with latest Emogrifier Library.

This one is already rtbc, so i re-rolled the patch in the other issue to apply onto this one.

haggins’s picture

Thanks for the patch, it fixed the stripping issue.

ndf’s picture

Version: 7.x-1.x-dev » 7.x-2.0-beta1
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

john franklin’s picture

Version: 7.x-2.0-beta1 » 6.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)