Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Inline image in e-mail

  1. #11
    Join Date
    Apr 2008
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hello John,

    Earlier today I tried sending it with the full url to the image in the html-part. The result is that this image is automatically visible in Gmail and Android devices, but (off course...) not in Outlook. After that, I forwarded the e-mail I got in Outlook to Gmail, and suddenly the image in this Outlook-mail showed up! Just not visible in Outlook itself, as it seems. Probably a config somewhere, but I can live with that. At least the image (logo) is visible, and probably will be in most email-clients.

    Off course I've looked at your suggestions, and I've even sent out a tweet to James, who wrote this script. He already replied and confirmed that the url to the image needs to be the full url, so I'll use that (and perhaps will take another look into the Outlook-config).

    So thank you John and James!

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I haven't tried this stuff out but I've had a fairly good look at 3 of these PHP email scripts - three besides the one you were working on. From that I can tell that embedding the base 64 is the way to go, yet it's more complicated than what I at first suggested. Of the various PHP scripts I was looking at this one looks the easiest to use:

    http://www.phpclasses.org/package/36...tachments.html

    It's free, but requires a simple registration to download it. I think you might actually be happier with it. Two snippets (first from the main script page, the part you configure):

    PHP Code:
    #add image to be embeded
    $img1 $sec->embed('php-power-white.gif'); 
    Easy to just enter the relative url to your image. And the main function on the include that does the heavy lifting and ties it in with the rest of the email in the correct manner:

    PHP Code:
        function embed($file) {
            if(
    is_file($file)) {
                
    $basename basename($file);
                
    $fileinfo pathinfo($basename);
                
    $contentid md5(uniqid(time())).".".$fileinfo['extension'];
                
    $embedheader "--{$this->emailboundary}\r\n";
                
    $embedheader .= "Content-Type: ".$this->mime_type($file)."; name=\"{$basename}\"\r\n";
                
    $embedheader .= "Content-Transfer-Encoding: base64\r\n";
                
    $embedheader .= "Content-Disposition: inline; filename=\"{$basename}\"\r\n";
                
    $embedheader .= "Content-ID: <{$contentid}>\r\n\r\n";
                
    $embedheader .= chunk_split(base64_encode(fread(fopen($file,"rb"),filesize($file))),72)."\r\n";
                
                
    $this->embed[] = $embedheader;
                            
                return 
    "<img src=3D\"cid:{$contentid}\">";
            } else {
                die(
    'The File '.$file.' does not exsist.');
            }
        } 
    Now of course that won't work just on its own. It does show more or less how a proper cid is created (at least what's involved) and used with the base 64 embed. What you had was close, but lacked certain real time parts of the process and the direct linkage to the email, possibly even lacked proper placement for some of the parts, and had no provision for generating the base 64 code. Even with the above operating in its full code you would need GD or at least base64_encode (which might not require GD, not sure - most PHP comes with GD anyway).

    I'm still not convinced this will work in all email clients. But I suspect it will work in more than simply using the full url or embedding base 64 in the manner I had first suggested.

    But if you're happy with what you have now, I'm not complaining.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #13
    Join Date
    Apr 2008
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks John for all your effort.
    I'm just not sure yet how to attach this to my form...

  4. #14
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Right, I'm kind of looking at it, as it interests me. I have discovered that the script I "like" (because of its simplicity) is 2007 or so - So it's out of date.

    Before I discovered that, I thought the best thing would be to just switch to it. But now I'm thinking of possibly adapting what it reveals about base 64 embedded images into what you already had.

    The only other alternative would be to start from scratch with one of the more up to date mail packages, or just keep what you have now.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #15
    Join Date
    Apr 2008
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks John. I've been away for a few days, but I'll look into it soon.

Similar Threads

  1. Replies: 1
    Last Post: 03-24-2010, 06:25 PM
  2. mail form with image attachment
    By sujith787 in forum PHP
    Replies: 7
    Last Post: 08-15-2007, 10:18 AM
  3. Send an e-mail to a POP3 E-Mail account
    By tech_support in forum PHP
    Replies: 20
    Last Post: 04-19-2007, 03:00 AM
  4. Replies: 1
    Last Post: 04-16-2006, 05:50 PM
  5. link image mapping to mail to
    By mush in forum HTML
    Replies: 1
    Last Post: 03-17-2005, 03:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •