I am having a problem taking both information from a form along with a file. I can either receive an email with a file or a email with the form entries. My text is this:
I would prefer to send multiple files as well! I have been working on this way to long lol and would really appreciate everyones input. I am assuming it is something simple that I keep looking over. Just to clarify I am receiving email and it has an attached file. I am just not receiving the "$body" portion which is essential as well. Thanks ahead of time!PHP Code:<?php
$to= '_@gmail.com';
$subject= 'Application';
$from= 'Website';
$fname = $_POST['fname'] ;
$lname = $_POST['lname'] ;
$phone = $_POST['phone'] ;
$email = $_POST['email'] ;
$state = $_POST['state'] ;
$city = $_POST['city'] ;
$about = $_POST['about'] ;
$experience = $_POST['experience'] ;
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $fname";
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
$body= stripslashes ('fname ' . $fname . ' lname ' . $lname . ' phone ' . $phone . ' email ' . $email . ' state ' . $state . ' city ' . $city . ' about ' . $about . ' experience ' . $experience . $from) ;
$ok= mail( $to, $subject, $message, $headers, $body);
if ($ok) {
echo "<p>Form temporarily unavaliable</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?><title>sendmail.php</title>



Reply With Quote
Bookmarks