Hello i'm trying to send email from form^) Here is my code
<?php
$to = "some email";
$from = "site";
$subject = "Resume";
$boundary = "---";
if (isset($_POST['ok'])){
$filename = $_POST['fileField'];
$resumeLink = $_POST['linkField'];
$message = "Attachment: " .$resumeLink;
/* Headers*/
$headers = "From: $from
Reply-To: $from
";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
$body = "--$boundary
";
/* Add message */
$body .= "Content-type: text/html; charset='utf-8'
";
$body .= "Content-Transfer-Encoding: quoted-printablenn";
$body .= "Content-Disposition: attachment; filename==?utf-8?B?".base64_encode($filename)."?=
";
$body .= $message."
";
$body .= "--$boundary
";
$file = fopen($filename, "r"); //open file
$text = fread($file, filesize($filename)); //read file
fclose($file); //close file
/* Add message type */
$body .= "Content-Type: application/octet-stream; name==?utf-8?B?".base64_encode($filename)."?=
";
$body .= "Content-Transfer-Encoding: base64
";
$body .= "Content-Disposition: attachment; filename==?utf-8?B?".base64_encode($filename)."?=
";
$body .= chunk_split(base64_encode($text))."
";
$body .= "--".$boundary ."--
";
if(mail($to, $subject, $body, $headers)){header("Location: /");}
}
?>
Attachment will send, but it size will be 1 byte without any content inside. Whats wrong?