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?
Welcome to the Tectite Forums! You can download and get support for our free PHP FormMail (form processor) and other free software.
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.
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?
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:
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.PHP Code:
$userfile = $_SERVER['DOCUMENT_ROOT'].'/path_to_image/image.png';
$fp = fopen($userfile, "r");
$file = fread($fp, filesize($userfile));
$file = chunk_split(base64_encode($file));
$mime_boundary = md5( uniqid(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 );
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?
ur reasons make a lot of sense![]()
sending an image is one thing, sending an HTML with lots of images....don't know.
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.
That's the hard part - if you can figure that out it would help me figure out how to achieve this in FormMail.I'm not 100% sure how to do it so I can use the image in HTML (i.e., <img src="image.png" />)
Russell Robinson - Author of Tectite FormMail and FormMailDecoder
http://www.tectite.com/
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/
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.
Hi, just checking in to see if this is possible yet.
Thanks!
Mp
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/
Hi Russell. Thanks for the information...and the great program! I will update my pages accordingly.
Thanks again!
Mp
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks