I seem to be missing something here. I've followed the configuration for emogrifier however I can't seem to get it functioning at all with simplenews and when sending a test from htmlmail, it does fire the emogrifier script (i simply put in a debug_backtrace() in the emogrifier.php script and got a return krumo) but the inline styles do not show up in the email.
I'm using a custom theme for htmlmail with one style sheet and a custom text format identical to the one suggested (pathologic, emogrifier, tranliteration, etc)

Is there anything to suggest in order to debug this? For example, is there somewhere I can make sure the css stylesheets from my theme are being sent to emogrifier.

Also not sure if this is an issue, but i am using localhost to send the mails.

thanks again!

Comments

blasthaus’s picture

Title: emogrifier and simplenews not working for me » emogrifier path issue when base_path() and DRUPAL_ROOT contain same 'sitename' folder

I found out the reason I was having problems was related to the path not being correct in the url_to_realpath() function in url_to_path.inc
realpath(DRUPAL_ROOT . base_path() . $path); for me instead returns the sitename twice

'Users/username/Sites/sitename/sitename/sites/all/themes/mytheme/css/mytheme.css'

DRUPAL_ROOT : /Users/username/Sites/sitename
basepath() : /sitename/
$path : sites/all/themes/mytheme/css/mytheme.css

Is there something that could work in this case where Drupal has defined my DRUPAL_ROOT and basepath() and both contain the same folder? I just did a basic drush drupal install of this site, no symlinks or anything, so I suspect other people may encounter this

thx
-wil
ps changing title

blasthaus’s picture

I'm not a php expert but this is how I solved this, let me know if its at least possible to do some error checking on this function. Here's a start.

function url_to_realpath($url) {
  $path = url_to_path($url);
  if ($path) {
	$realpath = DRUPAL_ROOT . base_path();
	if ($match = preg_replace("/\b([\w\/]+)(\\1)+/i", "$1", $realpath)) { 
		drupal_set_message(t('Your DRUPAL_ROOT and base_path() for Emogrifier module contain duplicate directories. <br /> 
		The paths to your CSS stylesheets for Emogrifier were therefore set to @match/ and not @realpath. <br />
		See: url_to_path.inc in Emogrifier module (line 128)', array('@match' => realpath($match), '@realpath' => $realpath, )), $type = 'warning', $repeat = FALSE);
		return realpath($match . $path);
		}
	else return realpath($realpath . $path);
  }
  return FALSE;
}
pillarsdotnet’s picture

Assigned: Unassigned » pillarsdotnet
pillarsdotnet’s picture

DRUPAL_ROOT should point to whatever was the current working directory when index.php was loaded.

base_path() just returns $GLOBALS['base_path'], which is set by drupal_settings_initialize() by looking at $base_url or $_SERVER['SCRIPT_NAME']

I originally used realpath('.' . $path) but switched to realpath(DRUPAL_ROOT . base_path() . $path) in response to Damien Tournoud in #1113588-25: Provide find_conf_path() function by re-factoring reusable code from existing conf_path() function..

Cross-linking with that issue.

Looks like I should have used realpath('.' . base_path() . $path).

pillarsdotnet’s picture

Status: Active » Needs review
StatusFileSize
new6.05 KB
new8.7 KB

Could you try the attached version and see if it works for you?

blasthaus’s picture

thanks for taking a look. above doesn't work on my localhost but does on live site
below works on both:

    return realpath($_SERVER['DOCUMENT_ROOT'] . base_path() . $path);

i never had any problem with the module not working on a live site.

just to be clear, drupal is set up like this on my localhost http://localhost/drupal

  1. base_path() returns /drupal/
  2. DRUPAL_ROOT returns /Users/username/Sites/drupal
  3. $_SERVER['DOCUMENT_ROOT'] returns /Users/username/Sites

on live site

  1. base_path() returns /
  2. DRUPAL_ROOT returns /home/username/drupal
  3. $_SERVER['DOCUMENT_ROOT'] returns /home/username/drupal

sidenote: nothing was done out of the norm for this drupal install on my localhost
RewriteBase not on in .htaccess and no base_url declaration in settings.php

pillarsdotnet’s picture

Status: Needs review » Postponed (maintainer needs more info)
StatusFileSize
new6.05 KB
new8.69 KB

Thanks very much for your help on this issue.

Looks like I can't use DRUPAL_ROOT in conjunction with base_path().

Could you please try the attached version and let me know if it works for you? I really appreciate your assistance in testing.

blasthaus’s picture

I can confirm it works on both my localhost and a live site. Thanks a lot. It was also a helpful exercise for me. I didn't test it on a multi-site set up which would be also important to check that DRUPAL_ROOT returns something like /home/username/drupal/sites/yoursitename and not just /home/username/drupal

pillarsdotnet’s picture

Version: 7.x-1.13 » 7.x-1.14
Status: Postponed (maintainer needs more info) » Fixed

Thanks so much for your help. Fix released as 7.x-1.14.

Status: Fixed » Closed (fixed)

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