Hi, Now i can able to send a mail with attachment and i can able to retrieve too. But now my problem is i can't able to send a mail with word document file as attachment. By using the following code i can able to send mail with only image files(jpg, gif).
<?PHP
$target_path = basename( $_FILES['uploadedfile']['name']);
echo $target_path;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$to = '
revathy@yahoo.com';
$subject = 'PHP Mail Attachment Test';
$bound_text = "jimmyP123";
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
$headers = "From:
XX@yahoo.com\r\n";
$headers .= "MIME-Version: 1.0\r\n"
."Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n"
.$bound;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
.$bound;
//."hey my <b>good</b> friend here is a picture of regal beagle\r\n"
$file = file_get_contents($target_path);
$message .= "Content-Type: image/jpg; name=\"attached.jpg\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-disposition: attachment; file=\"attached.jpg\"\r\n"
."\r\n"
.chunk_split(base64_encode($file))
.$bound_last;
if(mail($to, $subject, $message, $headers))
{
echo 'MAIL SENT';
} else {
echo 'MAIL FAILED';
}
?>
Can you please correct the code for attaching word document?