Emailing & header
| From: | Jan De Luyck | Date: | Fri, 23 Jun 2000 19:29:13 +0000 |
| Subject: | Emailing & header | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-2853@lists.php.net to get a copy of this message | ||
Hi there
I've been trying to create a script that does the following:
everyday there is a new 'userfriendly' cartoon (I guess most people know
this). Now I've created a script that parses the
www.userfriendly.org/static/index.html in order to get the correct filename
of the image wanted. This works out great.
Then, after this, I use a header( "Content-type: image/gif" ); to display it
on the
browser window. This all works great.
But what I also want this script to do, is to email me the image. I have no
access to any 'image' functions of php (due to lack of image lib). Is there
any way to send an 'html' email with a header in it so that the image would
come out okay?
Thanks!
Jan De Luyck
Addendum: script code:
<?php
$url="http://www.userfriendly.org/static/index.html";
$search1 = "SRC=\"http://www.userfriendly.org";
$search2 = "/cartoons/archives";
$email="jandeluyck@gmx.net";
$subject="Daily Userfriendly Static Image";
$file = fopen($url,"r");
unset ($buffer);
while (! feof($file))
{
$buffer = $buffer . fgets($file,4096);
}
fclose($file);
$blah=strchr($buffer,$search1);
$blah=strchr($blah,$search2);
for($i=0; $i < strlen($blah); $i++)
{
$character = $blah[$i];
if ($character == '"') break;
}
for ($j=0; $j <= $i - 1; $j++)
{
$cartoon_name = $cartoon_name . $blah[$j];
}
for ($i=0; $i < strlen($cartoon_name); $i++)
{
$character = $cartoon_name[$i];
if ($character == 'x') break;
}
for ($j=$i; $j < (strlen($cartoon_name)-1); $j++)
{
$cartoon_name[$j] = $cartoon_name[$j+1];
}
$cartoon_name = substr($cartoon_name,0,-1);
$cartoon_name = "http://www.userfriendly.org" . $cartoon_name;
header("Content-type: image/gif");
$file = fopen($cartoon_name,"r");
while (!feof($file))
{
$buffer=fread($file,4096);
$picture = $picture . $buffer;
echo $buffer;
}
fclose($file);
mail($email,$subject,"<a
href=\"http://www.blindguardian.org/temp/uf.php3\">Click
here</a>","From:
webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" .
phpversion());
?>