Hi,
I have created a php script to send an image with an email. But my image dows not get mailed. Here is my code. Plz help me to figure out the problem.
<?php
$unique_sep = md5(uniqid(time()));
$headers = "From: $from\r\n";
$headers.="MIME-Version: 1.0\r\nContent-Type:multipart/mixed;boundary=\"$unique_sep\";\r\n";
$headers.="charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding:7bit\r\n\r\n";
$headers.="if you are reading this then your email client does not support MIME.\r\n";
$headers.="Sent with mail attached";
$headers.="--$unique_sep";
$headers.="Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
$headers .= "Hello message fom chamsy\r\n\r\n";
$file ="C:\Program Files\Apache Group\Apache2\htdocs\chamal.JPG";
if(file_exists($file))
{
$headers .= "--$unique_sep\r\n";
$headers .= "Content-Type:image/jpeg; ".
"name=\"chamal.JPG\"\r\n";
$headers .= "Content-Transfer-Encoding: ".
"base64\r\n";
$headers .= "Content-Disposition: attachment\r\n\r\n";
$filedata = implode(file($file),'');
$headers .= chunk_split(base64_encode($filedata));
}
else
{
echo "cant find the file";
}
$headers .= "--$unique_sep--\r\n";
mail("chamalsl@yahoo.com","chamsy","message from chamsy",$headers);
mail("chamal@mail.ewisl.net","chamsy","message from chamsy",$headers);
mail("idreams3000@hotmail.com","chamsy","message from chamsy",$headers);
?>
Thanks a lot,
chamal.