[mod] Adding embedded images to emails

3rd party code for phpList

Re: Not sure what I am doing wrong!

Postby tauno » 6:08pm, Tue 23 Oct, 2007

You have in some places code like this:
Code: Select all
for($i=0; $i<count>get_template_image($templateid,$html_images[$i])){


It doesn't make any sense, the $i<count> part specifically. Where did you get this?

I just tried to post the whole code, but when I did the preview, it was all screwed up??! The preview of my code showed errors similar in your post. It seems that this forum tries to reformat the code and messes it up in the process.

I'll try it here to prove my point:
Code: Select all
   
      for($i=0; $i<count>image_exists($templateid,$images[1][$i])){
          $html_images[] = $images[1][$i];



yep, it did it again. The first line of the above is suppose to be
Code: Select all
for($i=0; $i<count($images[1]); $i++){


Anyway, there is nothing I can do about this (forum admins, please take notice of this bug). You have to follow the instructions in previous posts. You can also email me at tauno at eesti dot ca and I can send you the whole file.
tauno
phpList newbie
 
Posts: 3
Joined: 2:14am, Wed 17 Oct, 2007

Postby wahahey » 10:29am, Wed 24 Oct, 2007

I've upgraded to the latest version of PHPlist and the fix works now. I was avoiding doing it because I didn't think it was essential for this fix.

Thanks for your help Tauno.
wahahey
phpList newbie
 
Posts: 2
Joined: 11:06am, Tue 23 Oct, 2007

make sure your included images are accessible

Postby Peter Stadie » 7:01am, Fri 26 Oct, 2007

Some of you might secure the phplist directory with authentication. Don't forget that even if you send out emails with cid images they still need to be downloaded from the server. You can make a simple test, restore your original version of the class.phplistmailer.php. Than just include some images and view the received email. Normally you should now be asked to right click on it to download it. Just do it and see what happens. If there is just a red cross left and no image is downloaded, right click (Outlook) on it and see the source. You should find you image somewhere. Now, copy the URL and paste it into a browser. If it now shows up, than you probably have an open session in this browser. Change to another browser and try the same, in case you don't have an open session, the authentication box will pop up. Solution is simply to make the phplist directory public and only secure the admin directory below the path.

Hope it helps.
Peter Stadie
phpList newbie
 
Posts: 2
Joined: 3:03pm, Fri 21 Sep, 2007

The fix you are all looking for.

Postby danjfoley » 8:12pm, Wed 14 Nov, 2007

The problem has to do with the following line:

Code: Select all
$content=file_get_contents($html_images[$i],FALSE,NULL);


For some the file_get_contents function is not returning the images content like it should.

There are two possible problems.

1. Depending on your server, the function might not have permission to open up remote urls. And since phplist makes everything a complete url (even local images) it won't open. If this is the case you probably will get a php error when you try this. In order to fix this you either figure out (via your web host) how to get access to remove urls, or use some code to change the remote url to a local url.

here is what i have done to fix the above.

A. in class.phplistmailer.php

replace the line:
Code: Select all
$content=file_get_contents($html_images[$i],FALSE,NULL);


with:
Code: Select all
$image_file = $html_images[$i];
$image_file = str_replace($phplist_url_root,$phplist_file_root,$image_file);   
$content=file_get_contents($image_file);


you'll notice that i have use 2 new configuration variables $phplist_fileroot and $phplist_url_root.

So you will have to add the follow 2 lines to your main config.php files

Code: Select all
$phplist_file_root = "/your/file/root/";
$phplist_url_root = "http://www.yourdomain.com/yourrootdir/";


of course replace your actual file root and domain.

The other problem is:

2. The file_get_contents function has the wrong parameters.

If you just have this problem, just do the following:

replace the line:
Code: Select all
$content=file_get_contents($html_images[$i],FALSE,NULL);


with:
Code: Select all
$content=file_get_contents($image_file);
Last edited by danjfoley on 8:17pm, Wed 14 Nov, 2007, edited 3 times in total.
danjfoley
phpLister
 
Posts: 6
Joined: 7:58pm, Wed 14 Nov, 2007

Postby danjfoley » 8:14pm, Wed 14 Nov, 2007

by the way the last post of:

Don't forget that even if you send out emails with cid images they still need to be downloaded from the server.


is completely incorrect. We call it embedding images for a reason. They are embedded. If you have the red x, you have having the problem described in my last post.[/quote]
danjfoley
phpLister
 
Posts: 6
Joined: 7:58pm, Wed 14 Nov, 2007

problems after moving to PHP5

Postby jechilt » 4:45am, Fri 28 Dec, 2007

We recently had our account moved to a new server running PHP5. They disabled some features and want us to use cURL in place of file_get_content.

Here is my work-around:
Code: Select all
$image_file = $html_images[$i];
$image_file = str_replace($phplist_url_root,$phplist_file_root,$image_file);   


//$content=file_get_contents($image_file);
    $url = image_file;

    // As some PHP hosts switch off file_get_contents, so we configure with cURL

        $ch=curl_init($url);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $rsp=curl_exec($ch);
        // assign variable to $content for below
        $content = $ch;
        echo $content;
        curl_close($ch);


Whether I change to this code snip or not, the email sent has the correct references but the image does not show up.
The archive messages can be viewed just fine, images in place. It is only the email....we get the blank box with red X. I have looked at PHP.net and all over this forum with no solution.
The server administrators are at a loss and tell me to contact phplist.

I am in dire need of getting this working....can anyone help?
jechilt
phpLister
 
Posts: 6
Joined: 12:12am, Mon 17 Sep, 2007

Re: [mod] Adding embedded images to emails

Postby Helveticus » 3:00pm, Tue 06 Aug, 2013

Delete this. Wrong thread.
Helveticus
PL Geek
 
Posts: 64
Joined: 10:22pm, Sun 28 Jul, 2013

Previous

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 3 guests