Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

It won't work and I'm angry ;-(

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
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 = &quot;&quot;;
$pic = &quot;&quot;;

// find folder
if ($handle = opendir('files/')) {

while (false !== ($file = readdir($handle))) {

if ($file != &quot;.&quot; && $file != &quot;..&quot;) {

// format files
if(ereg(&quot;.html&quot;, $file) OR ereg(&quot;.htm&quot;, $file)) {


// gather html
$file = &quot;files/&quot; . $file;
$to_use = fopen($file, &quot;r&quot;);
while (!feof($to_use)) {
$html .= fgets($to_use, 2000);
}

} else {

// gather pics
$file = &quot;files/&quot; . $file;
$to_use = fopen($file, &quot;rb&quot;);
while (!feof($to_use)) {
$pic .= fgets($to_use, 2000);
}

}

}

}

closedir($handle);

}

// html header
$headers = &quot;From: me@me.com\r\n&quot;;
$headers .= &quot;MIME-Version: 1.0\r\n&quot;;
$boundary = uniqid(&quot;HTMLDEMO&quot;);
$headers .= &quot;Content-Type: multipart/alternative&quot; . &quot;; boundary = $boundary\r\n\r\n&quot;;
$headers .= &quot;This is a MIME encoded message.\r\n\r\n&quot;;
$headers .= &quot;--$boundary\r\n&quot; . &quot;Content-Type: text/plain; charset=Shift_JIS\r\n&quot; . &quot;Content-Transfer-Encoding:base64\r\n\r\n&quot;;
$headers .= chunk_split(base64_encode(&quot;This is the plain text version!&quot;));
$headers .= &quot;--$boundary\r\n&quot; . &quot;Content-Type: text/html; charset=Shift_JIS\r\n&quot; . &quot;Content-Transfer-Encoding:base64\r\n\r\n&quot;;
$headers .= chunk_split(base64_encode($html));

$headers .= &quot;------=_NextPart_000_0001_01C238B1.6F780A60\r\n\r\n&quot;;
$headers .= &quot;Content-Type: image/gif;\r\n&quot;;
$headers .= &quot;name=\&quot;logo.gif\&quot;\r\n&quot;;
$headers .= &quot;Content-Transfer-Encoding: base64\r\n&quot;;
$headers .= &quot;Content-Location:
$headers .= chunk_split(base64_encode($pic)) . &quot;\r\n\r\n&quot;;

$headers .= &quot;------=_NextPart_000_0001_01C238B1.6F780A60--\r\n\r\n&quot;;

// send mail
mail(&quot;me@me.com&quot;, &quot;test&quot;, &quot;&quot;, $headers);

?>




My Work...
...and More...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top