Closed (duplicate)
Project:
Emogrifier
Version:
7.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2011 at 01:37 UTC
Updated:
23 Apr 2015 at 06:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pillarsdotnet commentedCheck your status page. Are you sure the third-party emogrifier library is loading properly?
Check your admin/reports/dblog (watchdog, or error messages) page. Are there any error messages there?
Comment #2
bensey commentedThanks for the reply pillarsdotnet,
Library placed in /libraries/emogrifier/emogrifier.php.
yes, status page says all the right things:
Emogrifier class library: Available: The Emogrifier class library was found.
DOM extension : Enabled
No errors or issues logged in watchdog.
When I add emogrifier to an input format used for sending emails, as mentioned above, the email arrives without
headorbodytags, instead wrapped in adiv.The css within the
styletag insideheadis all gone with those tags.I don't have many classes on tags, the styles are more defining html tags, the
bodyfont, headings, paragraph margins etc, keeping it all pretty simple.On a thorough inspection, the one class I'm using on some paragraph tags have had their
classattributes removed from the tags. Other than that the HTML seems the same.So it seems to be doing something, but not what's expected, baffled..!
Comment #3
aangel commentedSame thing happening for me with the 6.x version. Doesn't appear to be working correctly (all libraries loading, etc.).
Comment #4
pillarsdotnet commentedI've been offline for some time but will try to troubleshoot this. Perhaps it would help if I made a screencast of setting up HTMLMail, MailMIME, MailSystem, Emogrifier, etc. from a clean install. Then you could watch the screencast and identify what, if anything, we're doing differently.
Comment #5
lmeurs commentedI am not sure whether this is the solution, but I'm going to give it a try.
In emogrifier.module (7.x-1.17) at line 101 the script searches for <style>-tags and checks the type and media attributes. If the style block contains @import rules, the URL's are stored in an array. But the rest of the rules in the block seem to be ignored. Is this supposed to happen?
A quick fix might be adding
$styles[] = $blocks[3][$block];at line 109, which results in:Maybe the @import rules need to be removed before storing the block in the $styles array, I don't know if they can hurt anyone... :-)
And while I am at it, a simple script like this
results in the next HTML:
By removing the PCRE_UNGREEDY modifier (U) and adding
trim()at line 160 (or 161 with earlier modification),the new HTML looks like:
without <html>-tag and extra newlines.
Anyone knows why this PCRE_UNGREEDY modifier (U) is here?
Comment #6
henrijs.seso commentedSame in 6.x-1.17
@pillarsdotnet why do you mention MailMIME in #4?
Comment #7
pillarsdotnet commented@#5 Posted by lmeurs on March 7, 2012 at 11:53am:
Thanks so much. Because I am lazy, could you please express that change as a patch?
Comment #8
lmeurs commentedI'd love to, but do not know how. Still have to take the time learn all about patches...
Comment #9
jmonma commentedAre you all using emogrifier with htmlmail? The issue might be with that module: http://drupal.org/node/1439658
Comment #10
plepe commentedI found a bug in the Emogrifier module. If no @import is found, the content of
is being discarded. Check the attached patch for details.Comment #11
pillarsdotnet commentedThanks.
Comment #12
tchopshop commentedI have been attempting to get emogrifier working for an entire day... Nothing works! I have tried both patches above. I am using the latest html mail, mail system, simplenews. I have the emogrifier.php in a directory in libraries/emogrifier. I'm not using echo or mail mime. I have a custom mail theme in which I have the htmlmail--simplenews.tpl.php template, mail.info and mail.css, which is referenced by the .info file. I have an email text format that uses Emogrifier, Pathologic, Transliteration, and the Wysiwyg Filter -- because I need to screen out video in the node body.
I also have a simplenews-newsletter-body.tpl.php in the admin theme "Seven", because that's the only way I could get it to recognize the theme. The htmlmail--simplenews.tpl.php prints a wrapper around
echo $body;, and the simplenews template does the rest.Originally I had everything outputting from the htmlmail--simplenews.tpl.php but after many hours failing to get emogrifier to work, I added the simplenews template in an attempt to more easily extract the field variables, since it's more direct from the Simplenews template than from the htmlmail template. I thought I would extract the variables and theme them inline. But I failed at extracting these Drupal 7 variables... it's just taking too long to figure out each one.
If emogrifier were working, I could simple target the design in the css file. But I can't seem to get anywhere. It's very frustrating.
I'm used to using Mime Mail with Simplenews, which works much more easily in terms of embedding CSS inline. But I have to use the SMTP module this time, and evidently Mime Mail does not work with SMTP.
I need to be able to target the fields inside my node somehow!
Also where should the CSS file be? I have it in my mail theme, my seven theme and in my default theme (just for good measure).
Or do I need to put the styles in the head not in a stylesheet? Or do I need to link to the stylesheet from the head? I assumed you just link to the stylesheet from the .info file in the custom mail theme. I've tried many variations of all these things.
Please help.
Comment #13
nzcodarnoc commentedI was having the same problem, here's what I did to resolve it in my instance.
Instead of including the styles in the template, I put them in a separate .css file, and included the file using the following syntax:
Comment #14
tchopshop commentedThank you, that finally gave me a break through. Although I couldn't get the @import working... I simply created a hardcoded stylesheet link.
Comment #15
pasqualle#10 works, just the whitespace issues should be fixed
- replace tabs with 2 spaces
- add space around the '=' character
then the patch should look like this
Comment #16
alexh58 commentedI'm surprised this isn't resolved yet—Spent a good chunk of time pulling my hair out over check_plain not working with this filter.
Anyways, I've encompassed both of lmeurs' edits in a patch attached here. The one in http://drupal.org/node/1336106#comment-6048704 doesn't resolve the PCRE_UNGREEDY modifier needing removal (otherwise you still end up with that lonely closing html tag).
Please review! I don't like walking around with a patched module ;-)
Comment #17
alexh58 commentedAnd for my purposes, here is a backport for D6.
-Alex
Comment #18
raekjaer commentedI am using commerce invoice receipt, which uses emogrifier to prepare invoice for email. The problem with missing HTML, HEAD and BODY also appears here.
The attached patch clones the original string and inserts emogrified text into it before returning. But only if there is a BODY tag in the original string - otherwise we bypass the insertion.
This approach is only tested in my limited setup - and it only addresses half of the original issue.
Casper
Comment #19
geek-merlinWOW. Puzzled together the different patches.
While wrapping my head around these i also added some comments to make things reviewable.
Some remarks:
* Regexp parsing is bullshit, this should be refactored to use a HTML parser.
* We should really have split this issue.
* We should #1824562: Prepare some tests to be added
Now please everyone test this so we can get this in.
Comment #20
jonne.freebase commentedPatch #19 worked for me, but generated a few warnings in my case because I didn't use media queries in my template (i assume). I basically added the following to axel.rutz' patch:
Comment #21
geek-merlinexactly what i had to add and now works without warnings.
so setting to reviewed.
Comment #22
roball commentedCan't believe this critical bug is still in the current production releases 7.x-1.18 and 6.x-1.18 and no fix has yet been committed. I have also hit this bug with 6.x-1.18, having the following simple HTML source:
The Emogrifier module will break this complete and styled HTML page to the following incomplete and unstyled HTML:
The workaround is to modify the
styletag to contain:The
media="all"and@import url("");must be added. This results in the styled, but still uncomplete HTML page:The latest patch in #20 for D7 is not a valid patch; the latest D6 patch from #17 does not solve the problem. This problem needs urgent attention by the module author (his last contribution was 7 months ago, just saying "Thanks", but not taking any action).
Comment #23
roball commentedThe solution is to apply the latest patch posted at #1842946: Modify HTML code only by the Emogrifier library - forget all patch attempts posted here! There is no need to additionally process the HTML code by this module at all - this is just useless, complicated and error-prone.
After applying that patch (for D6), the resulting HTML page is complete, valid and inline-styled properly, looking like this:
:-)
Comment #24
roball commentedChanging the status of this issue back to "needs review" since it has been solved in the other issue (#1842946: Modify HTML code only by the Emogrifier library). Once that other issue has been confirmed to be reviewed & tested, this issue can be closed.
Comment #24.0
roball commentedfixing tags in body, as they were stripped...
Comment #25
colepacak commentedI created a separate module using a stripped-down version of the Emogrifier module. It seemed like all the regex was the culprit.
Created a new text format using this new filter and selected the text format within the HTML Mail module post-filtering settings.
No changes made on htmlmail.tpl.php.
Comment #26
jacob.embree commentedThe fix for this is to switch to version 2.
Comment #27
geek-merlinDoes this mean 1.x is discontinued? in this case it must be unpublished from the module page.
Comment #28
socialnicheguru commentedComment #35
roball commentedThe bug has been fixed in the issue #1842946: Modify HTML code only by the Emogrifier library, thus I am closing this one as a duplicate.