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.gi f";
$fp = fopen($file,"r" );
$fcontent = fread($fp ,filesize($file ));
fclose($fp);
$content = chunk_split(bas e64_encode($fco ntent));
echo $fcontent;
$sep = md5(time());
$name = basename($file) ;
$headers = "From:kencana@k esuma.com\r\n";
$headers .= "Reply-To:kencana@kesu ma.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=\"$fil e\"\n";
$body .= "$content\n ";
$body .= "--$sep--";
mail("kencana@k esuma.com","Thi s is the subject",$body, $headers);
[/PHP]
Thank you very much
Regards,
Kencana
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.gi f";
$fp = fopen($file,"r" );
$fcontent = fread($fp ,filesize($file ));
fclose($fp);
$content = chunk_split(bas e64_encode($fco ntent));
echo $fcontent;
$sep = md5(time());
$name = basename($file) ;
$headers = "From:kencana@k esuma.com\r\n";
$headers .= "Reply-To:kencana@kesu ma.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=\"$fil e\"\n";
$body .= "$content\n ";
$body .= "--$sep--";
mail("kencana@k esuma.com","Thi s is the subject",$body, $headers);
[/PHP]
Thank you very much
Regards,
Kencana