Hi all,
I got problem in sending email with image file attached. the problem is that i can't see the image, apart from that i also try to attach a txt file and it gave me no luck. the txt file in the mail attachment is empty.
Tha following is my code, i hope somebody can help me out.
[PHP]
$file="Globe.gif";
$fp = fopen($file,"r");
$fcontent = fread($fp ,filesize($file));
fclose($fp);
$content = chunk_split(base64_encode($fcontent));
echo $fcontent;
$sep = md5(time());
$name = basename($file);
$headers = "From:kencana@kesuma.com\r\n";
$headers .= "Reply-To:kencana@kesuma.com\r\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=$sep";
$body = "--$sep\n";
$body .= "Content-Type: text/plain;\n";
$body .= "Content-Transfer-Encoding: 8bit\n\n";
$body .= "Hello There!\n";
$body .= "--$sep\n";
$body .= "Content-Type: image/gif; name=\"$file\"\n";
$body .= "Content-Transfer-Encoding: base64;\n";
$body .= "Content-Disposition: attachment; filename=\"$file\"\n";
$body .= "$content\n";
$body .= "--$sep--";
mail("kencana@kesuma.com","This is the subject",$body, $headers);
[/PHP]
Thank you very much
Regards,
Kencana