I have a form which i am planning to use to let users upload files to a folder and at the same time send an email back to me with name, email address and comments from the user.

The part of the script that uploads the file works perfectly so i'm hoping i won't have to find an alternative to it. My problem is the part that sends the email. It validates, by which i mean it returns the success page, but does not send any email to me.

The code is copied from the email form that already exists (and works) on the site, which successfully sends the email, but when i try to merge the two, only the file upload works.

Thanks in advance, here is the code:

Code:
<?php
//==========
// Upload script
//==========

// ==============
// Configuration
// ==============
$uploaddir = "../upload";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, JPG, jpeg, gif, png, pdf";
// These are the allowed extensions of the files that are uploaded
$max_size = "10485760";
// 50000 is the same as 50kb
$max_height = "6000";
// This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "6000";
// This is in pixels - Leave this field empty if you don't want to upload images

// Check Entension
$extension = pathinfo($_FILES['file']['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}

// Check File Size
if ($ok == "1") {
if($_FILES['file']['size'] > $max_size)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_SIZE\">";
exit;
}

// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']);
if($width > $max_width || $height > $max_height)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_DIMENSION\">";
exit;
}
}


// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);

}
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_OK\">";
} else {
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_EXTENSION\">";
}
?>


<?php

// get posted data into local variables
//$EmailTo = "webmaster@eleganteditions.com";
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "info@fabiobasile.com";
$Subject = "A new file was uploaded";
$name = Trim(stripslashes($_POST['name'])); 
$email = Trim(stripslashes($_POST['email']));
$comments = Trim(stripslashes($_POST['comments']));

// validation
$validationOK=true;
if (Trim($name)=="") $validationOK=false;
if (Trim($email)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=../ERROR.html\">";
  exit;
}


// prepare email body text
$Body .= "name: ";
$Body .= $name;
$Body .= "\n";

$Body .= "e-mail: ";
$Body .= $email;
$Body .= "\n";

$Body .= "comments: ";
$Body .= $comments;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page 
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_OK\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=../ERROR.html\">";
}
?>