Hello,
I made the following code that will refuse displaying
properly the gif file which is supposed to show off inside
the html mail sent by the code.
The html is displayed properly but there are only garbled
characters in place of the gif file.
A BIG THANKS to the one who will kindly help.
Have a good day all.
<?php
// before start
$html = "";
$pic = "";
// find folder
if ($handle = opendir('files/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." {
// format files
if(ereg(".html", $file) OR ereg(".htm", $file)) {
// gather html
$file = "files/" . $file;
$to_use = fopen($file, "r"
while (!feof($to_use)) {
$html .= fgets($to_use, 2000);
}
} else {
// gather pics
$file = "files/" . $file;
$to_use = fopen($file, "rb"
while (!feof($to_use)) {
$pic .= fgets($to_use, 2000);
}
}
}
}
closedir($handle);
}
// html header
$headers = "From: me@me.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLDEMO"
$headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=Shift_JIS\r\n" . "Content-Transfer-Encoding:base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This is the plain text version!");
$headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=Shift_JIS\r\n" . "Content-Transfer-Encoding:base64\r\n\r\n";
$headers .= chunk_split(base64_encode($html));
$headers .= "------=_NextPart_000_0001_01C238B1.6F780A60\r\n\r\n";
$headers .= "Content-Type: image/gif;\r\n";
$headers .= "name=\"logo.gif\"\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Location:
$headers .= chunk_split(base64_encode($pic)) . "\r\n\r\n";
$headers .= "------=_NextPart_000_0001_01C238B1.6F780A60--\r\n\r\n";
// send mail
mail("me@me.com", "test", "", $headers);
?>
My Work...
...and More...
I made the following code that will refuse displaying
properly the gif file which is supposed to show off inside
the html mail sent by the code.
The html is displayed properly but there are only garbled
characters in place of the gif file.
A BIG THANKS to the one who will kindly help.
Have a good day all.
<?php
// before start
$html = "";
$pic = "";
// find folder
if ($handle = opendir('files/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." {
// format files
if(ereg(".html", $file) OR ereg(".htm", $file)) {
// gather html
$file = "files/" . $file;
$to_use = fopen($file, "r"
while (!feof($to_use)) {
$html .= fgets($to_use, 2000);
}
} else {
// gather pics
$file = "files/" . $file;
$to_use = fopen($file, "rb"
while (!feof($to_use)) {
$pic .= fgets($to_use, 2000);
}
}
}
}
closedir($handle);
}
// html header
$headers = "From: me@me.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLDEMO"
$headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=Shift_JIS\r\n" . "Content-Transfer-Encoding:base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This is the plain text version!");
$headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=Shift_JIS\r\n" . "Content-Transfer-Encoding:base64\r\n\r\n";
$headers .= chunk_split(base64_encode($html));
$headers .= "------=_NextPart_000_0001_01C238B1.6F780A60\r\n\r\n";
$headers .= "Content-Type: image/gif;\r\n";
$headers .= "name=\"logo.gif\"\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Location:
$headers .= chunk_split(base64_encode($pic)) . "\r\n\r\n";
$headers .= "------=_NextPart_000_0001_01C238B1.6F780A60--\r\n\r\n";
// send mail
mail("me@me.com", "test", "", $headers);
?>
My Work...
...and More...