Okay, so is it weird for me to post a bug related to a patch that I created?

Well I thought I'd post it so that people knew about a bug with the html email functioning in massmailer while we try and track down the problem.

The problem: Image tags in html email messages should use absolute urls. But for some reason the absolute part of the urls are getting stripped out by PHPList. So <img src="http://www.example.com/images/photo.gif"> becomes <img src="/photo.gif">. And the images don't show up in the messages. Very odd.

The workaround: Use single quotes instead of double quotes. Don't know why, but it works.

Presumably when we know why this is happening, we'll fix it. In the meantime, use single quotes.

-Jeff

Comments

Mack Oberman’s picture

I would love to see this fixed.

Certain ISPs--speakeasy.net in particular--do not take kindly to the use of single-quotes. Their webmail system replaces all such Only local images are allowed. tags with Only local images are allowed.. Thus, a certain segment of my subscribers complain that the images are broken each time I send emails, because the single-quote workaround actually causes them problems.

bbaldo’s picture

I'm getting stuck with this issue, img absolute urls are being stripped anyway...
i have a 4.5.0 drupal installation with massmailer and phplist 2.9.3, anyone found a solution to this problem?

bbaldo’s picture

I found this solution: http://www.phplist.com/forums/viewtopic.php?t=1072&postdays=0&postorder=...

Basically: open file "class.html.mime.mail.inc" in /admin directory, then remove from the image_types array the image types who's url are being stripped. I commented three lines, see below:

    $this->image_types = array(
                  //'gif'  => 'image/gif',
                  //'jpg'  => 'image/jpeg',
                  'jpeg'  => 'image/jpeg',
                  'jpe'  => 'image/jpeg',
                  'bmp'  => 'image/bmp',
                  'png'  => 'image/png',
                  'tif'  => 'image/tiff',
                  'tiff'  => 'image/tiff'
                  //'swf'  => 'application/x-shockwave-flash'
                  );
Veggieryan’s picture

any gotten this working? even with quoting out all the tags in this array, my images are still blocked... civicspace 0.8.5

jeffmikels’s picture

Version: master » 4.6.x-1.x-dev

SOLUTION:

The problem comes in that phplist attempts to "embed" images as mime attachments to emails and then to change the href to refer to the embedded file. However, this doesn't work as expected when running through drupal because, I assume, it can't find the original file in the expected phplist image directory.

The other problem is that there are two files which do the stripping.

  • phplist/admin/class.phplistmailer.php
  • phplist/admin/class.html.mime.mail.inc

ASIDE: These two files appear to do the same thing, so I don't know why they are both there.

Here's the solution, and if I knew how to do a patch I would.

STEP ONE: edit the config file

add the following lines somewhere in /modules/massmailer/engines/phplist/config.php

// Have PHPList embed images as attachments.
define("EMBED_IMAGES",0);

STEP TWO: edit the class files

In each of the class files (mentioned above) there is a function called find_html_images. Modify that function like so (without the php tags of course):

function find_html_images($templateid) {
      if ( !EMBED_IMAGES ) return;
      // leave the rest of the function alone

email me if you have questions.