I've *almost* got this all figured out, but I'm hitting a stumbling block.

I'm attempting to get Invoice Receipt integrated with Emogrifier so that css is embedded in the emails when sent out. The System Status is reporting that Emogrifier is properly installed. I've created an input format for Emogrifier. I've changed Mime Mail to use Emogrifier as it's email format. And I've changed the mail settings so that my "Invoice Receipt module class" is set to Mime Mail. My site wide default is also Mime Mail.

The problem is, that final step doesn't seem to be taking. I've told Mime Mail not to use the site address when sending mail, but rather an alternate address. Other rules that fire emails send with this alternate email address, but Invoice Receipts seem to be ignoring Mime Mail entirely.

I tried dumping MimeMail and switching over to HTMLMail, but there's no change, I still see the css linked in my email, not embedded:

<link type="text/css" rel="stylesheet" href="http://www.MYSITE.com/sites/all/modules/commerce_invoice_receipt/theme/commerce_invoice_receipt.css?nlizh3" media="all">

I'm stumped. Any ideas what I'm doing wrong?

Comments

TrevorBradley’s picture

Status: Active » Closed (won't fix)

Digging further - it's either an emogrifier problem (which is running, but not converting my css), or a misunderstanding of what emogrifier does...

TrevorBradley’s picture

Category: Support request » Feature request
Priority: Normal » Minor
Status: Closed (won't fix) » Active

OK, I missed this obvious point in the Emogrifier documentation:

Emogrifier will grab existing inline style attributes and will grab <style> blocks from your HTML but it will not grab CSS files referenced in <link> elements (the problem email clients are going to ignore these tags anyway, so why leave them in your HTML?).

I've copied the commerce_invoice_receipt.css file contents into a style block. Without it, the email table formatting looks like junk.

A minor request for consideration: Shouldn't the commerce-order-invoice-view.tpl.php file contain a style block with css formatting by default, so that the email is formatted correctly once emogrifier is properly installed?

dasginganinja’s picture

I just faced this problem in 2.x-dev and am wondering why the module runs it through emogrify because it's loading the css through a non-inline method. I had to do a little bit of research as well before I found out that emogrify wasn't really but the problem but it was actually that of this module.

I ended up removing the default styles display:

print drupal_get_css($styles);

and put this code in place of it:

    $css = dirname(__FILE__) . '/commerce_invoice_receipt.css';
    $style = file_get_contents($css);
    printf('<style>%s</style>', $style); 

Now that the css is inline emogrifier works as expected. Hopefully we can come up with some solution for 1.x as well as 2.x.

jeremdow’s picture

This works, but really Emogrifier module is the problem -

This seems to be the underlying issue -
https://www.drupal.org/node/2195043

If we don't want to change this module -

For now we can use the Emogrifier 7.x-1.x branch - and any version of the Emogrifier class without the Pelago namespace.
https://www.drupal.org/node/1525964
https://github.com/jjriv/emogrifier/releases

It looks like the Emogrifier 7.x-2 beta branch was created to address this, but then ran into some maintainer issues.

This patch updates for the library change, but then (mistakenly?) also wipes out all the other functionality this module depended on -
https://www.drupal.org/node/2195043#comment-9164053
http://cgit.drupalcode.org/emogrifier/commit/emogrifier.module?id=9c9bed...

Install instructions here could note this until they work it out -

Or should I patch to remove the dependency and just call the library class directly?
https://github.com/jjriv/emogrifier#usage

aramboyajyan’s picture

Status: Active » Fixed

Thanks for reporting this! I'm updating the status; I finally got the time to fix this properly.

Related: #2414007: Allow to include a css file into style tag.

Commit: http://drupalcode.org/project/commerce_invoice_receipt.git/commit/1cd9258.

Status: Fixed » Closed (fixed)

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