I want to have a function that can sent out a html page.
such as calling function, mailthispage("foo.html"), will send out foo.html.
The following is the answer by steve about "send an html page by e-mail". But Steve's method send the image in the html page as a live link. <image src="http://www.foo.com/image1">. I want it to send out the image embeded in the e-mail, so people can re-read the e-mail offline too without broken image links.
Mark suggest a class
http://www.phpbuilder.com/snippet/detail.php?type=snippet&id=614
this e-mail class can send out image embeded e-mail. but this class is for creating e-mail by the programmer, you know where you want to put the image and what is the image path in advance. It is not for reading any html page into your e-mail body and send it out at free will.
I think the solution is combine these two answers together.
First read the html file, and pinpoint all the image tags in that html file. convert the image tag to imageid and convert the image into binary code with that imageid. and send them out both in e-mail body.
it seems that it should not be too difficult for a seasoned php master (not me). this question has been asked by paul a year ago, and i think by now there might be some component on the market now to do this work. "send this page by e-mail" is used by millions internet explorer users everyday. i guess php community should alreay come out with a approach to do the same task by using php now.
any information?
thanks.
Hui
Author: Steve Yelvington
Date: 2001-03-10 10:53:46
Subject: RE: Send HTML page with php
Read the page into a variable using fopen/fread or file/implode.
Call the mail() function, passing an additional email header to set the content type to text/html. The content type is what tells the mail viewer how to display the data.
$myfile = implode('',file('foo.html'));
$myheaders = 'From: foo@bar.com\nContent-type: text/html\n';
$recipient = 'somebody@somewhere.com';
$subject = 'This is HTML mail';
mail($recipient, $subject, $myfile, $myheaders);