Results 1 to 10 of 10

Thread: Images in HTML Email Template

  1. #1
    Join Date
    Dec 2005
    Posts
    32

    Default Images in HTML Email Template

    I have HTML email templates that include some images (a company logo and background image). Right now, the images are loaded from the internet (i.e., the source code is something like <img src="http://www.mysite.com/image.jpg">). But, I would rather send the images inline with the email so they don't have to be loaded from the internet (especially for people with Outlook and similar email programs that don't automatically load images from the web). Normally, I would do this with a mime subpart, but I'm not sure the FormMail will properly read a mime supbart in the email template since it's part of the email header.

    Anyone know how to embed images using the HTML email template? Thanks.

  2. #2
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: Images in HTML Email Template

    i dont think u can do this...at least i dont know how

    maybe if u can explain how u would get an email to embed the images, i could suggest something

    wots wrong with the full URLs?

  3. #3
    Join Date
    Dec 2005
    Posts
    32

    Default Re: Images in HTML Email Template

    That's what I'm afraid of. If I were just writing a script to send an email with an inline image, it would be something like this:
    PHP Code:
    $userfile $_SERVER['DOCUMENT_ROOT'].'/path_to_image/image.png';
    $fp fopen($userfile"r");
    $file fread($fpfilesize($userfile));
    $file chunk_split(base64_encode($file));

    $mime_boundary md5uniqid(mt_rand()) );

    $message .= "--$mime_boundary\n";
    $message .= "Content-Type: image/png\n";
    $message .= "Content-Disposition: inline\n";
    $message .= "Content-Transfer-Encoding: base64\n\n";
    $message .= "$file\n";

    $message .= "--$mime_boundary--\n\n";

    $headers "From: webserver@{$_SERVER['SERVER_NAME']}\n";
    $headers .= "Reply-To: webserver@{$_SERVER['SERVER_NAME']}\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/parallel; boundary=\"$mime_boundary\"\n";
    $headers .= "X-Mailer: PHP/".phpversion();

    $to 'someone@domain.com';

    $subject "An image";

    mail$to$subject$message$headers ); 
    Basically, it's using mime boundaries and headers to send the image with the email. I'm not 100% sure how to do it so I can use the image in HTML (i.e., <img src="image.png" />), but what I'm after is sending the image with the email not linking to an image on our webserver.

    There's a couple reasons I'd rather send the images with the email rather than link to them. First, a lot of mail programs (like Outlook) block images from being downloaded in emails unless the user choses to do so. Second, if the user is not connected to the internet when viewing the message, the images will not show up if they are linked. Third, every time someone views an email that came from our contact page (through the auto response), it's using bandwidth from our webserver to download the linked images.

    Any thoughts on whether adding the inline or attached images is possible?

  4. #4
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: Images in HTML Email Template

    ur reasons make a lot of sense

    sending an image is one thing, sending an HTML with lots of images....don't know.

  5. #5
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Images in HTML Email Template

    Hi,

    I've moved your thread to the Features Questions forum.

    It's an interesting topic. I'll have to do some research as to how you can have an HTML email that refers to its own images.

    I'm not 100% sure how to do it so I can use the image in HTML (i.e., <img src="image.png" />)
    That's the hard part - if you can figure that out it would help me figure out how to achieve this in FormMail.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  6. #6
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Images in HTML Email Template

    Hi again,

    Well it didn't take me long to find out how to do it.

    I just looked at some graphical spam I received.

    Also, found this article: http://people.dsv.su.se/~jpalme/ietf/mhtml.html

    So, now the hard part is figuring out the best way for the HTMLTemplate feature in FormMail to "pull together" all the components (images) and send it out in one HTML email.

    I've got some ideas about how to do this.

    This will have to go on the "TO DO" list for a future FormMail version.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  7. #7
    Join Date
    Dec 2005
    Posts
    32

    Default Re: Images in HTML Email Template

    That's awesome. I was trying to do the same thing as you -- find some emails with spam I could look at, but all the ones I had used a web address for images. I kept waiting to get something, but you beat me.

    Implementing is tricky while keeping the HTML email template system "user friendly" like it is now. Off the top of my head, if you were use file_get_contents, you could have an array of images to read and format into MHTML written at the beginning or end of the template, but then you would have to strip the array from the contents before sending the email so the php code wouldn't show in the email. But, that might require users to be more careful in formatting the templates. Seems kind of sloppy, too.

    It would be more complicated, but maybe you could have the user keep images for emails in a subfolder of the template folder and then search the HTML email template for the img tag, grab what is in the src attribute (maybe using pre_match_all and a regular expression to create an array of all img src attributes), look to see if the src starts with "http" and, if not, read the image matching the file name in the designated email template images folder, and format it to send with the email. I may be missing a step there, but it's been a long and late day.

    Those are just off the top of my head, but I'm not that familiar with what's in the formmail script as you would be. This would be an awesome feature if you can implement it. Very much appreciate it. Thanks again.

  8. #8
    Join Date
    Sep 2008
    Posts
    4

    Default Re: Images in HTML Email Template

    Hi, just checking in to see if this is possible yet.

    Thanks!
    Mp

  9. #9
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Images in HTML Email Template

    Hi,

    No, it's not yet implemented.

    You can try a workaround. Use <base href="http://yoursite/" /> in the head of the HTML template and then use relative URLs for the images.

    In theory, the email client should pull in the images from your website.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  10. #10
    Join Date
    Sep 2008
    Posts
    4

    Default Re: Images in HTML Email Template

    Hi Russell. Thanks for the information...and the great program! I will update my pages accordingly.

    Thanks again!
    Mp

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sending form results in an HTML email
    By russellr in forum HOWTO Guides and Tips
    Replies: 26
    Last Post: 12-Jan-2006, 09:31 PM
  2. HTML Email not working
    By Rich in forum FormMail Subscription Support
    Replies: 9
    Last Post: 23-Jul-2004, 10:11 PM
  3. Can I Include an Image in an HTML Email??
    By minskin in forum FormMail Subscription Support
    Replies: 4
    Last Post: 19-Jun-2004, 03:43 PM
  4. HTML email reply
    By aussieincanada in forum FormMail Subscription Support
    Replies: 5
    Last Post: 04-Jun-2004, 07:07 AM
  5. send an email in HTML
    By michecosta in forum FormMail Subscription Support
    Replies: 3
    Last Post: 25-May-2004, 09:18 PM

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
  •