Hi Everybody,
I want to send a doc file using mail function..
The doc file contains some images...and text..
The code I am using is as follows:
<?php
#gives the path of the file where the emials are stored
$email_path = $DOCUMENT_ROOT. "/wside/address1.txt";
//$attach = $DOCUMENT_ROOT. "wside/NaveenIBW_Global1.doc";
$attach = $DOCUMENT_ROOT. "wside/UpDateFeb2002.doc";
echo $attach;
$file_data =file($email_path);
$attach_size = filesize($attach);
//=================================================================================================
if ($attach != "none")
{
$file = fopen($attach, "r");
$contents = fread($file, $attach_size);
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
$mailheaders .= "MIME-version: 1.0\n";
$mailheaders .= "Content-type: multipart/mixed; ";
$mailheaders .= "boundary=\"Message-Boundary\"\n";
$mailheaders .= "Content-transfer-encoding: 7BIT\n";
$body_top = "--Message-Boundary\n";
$body_top .= "Content-type: text/plain; charset=US-ASCII\n";
$body_top .= "Content-transfer-encoding: 7BIT\n";
$body_top .= "Content-description: Mail message body\n\n";
$msg_body = $body_top . $msg_body;
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: application/octet-stream; name=\"$attach\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$attach\"\n\n";
$msg_body .= "$encoded_attach\n";
$msg_body .= "--Message-Boundary--\n";
// $to = "naveen@punelive.com";
$to = "naveen@emmasoftware.com";
$subject = "Weekly Newsletter from Jet Airways";
}
mail(stripslashes($to), $subject, $msg_body, $mailheaders);
//mail($to, stripslashes($subject), $msg_body, $mailheaders);
//=================================================================================================
?>
When I complie this script I get the following error:
"The document name or path is not valid. Try these suggestions :
Check the file permissions for the document or drive.
Use the file open dialog box to locate the file"
Can anybody help me out..as I have been trying this all day...and havent succeded as yet..The above script shows this word doc which is without images without any error but the doc file with images is giving error...
Please let me know asap
Thanks
Kajol