title: What's wrong with my AJAX contact form? (php mail())
body: <p>I`ve created my first ajax contact using jQuery and PHP form but it doesn't seem to work.</p>
  
  <p>My jQuery code:</p>
  
  <pre><code>var dataString = 'address=' + address + '&amp;title=' + title + '&amp;name=' + name + '&amp;mail=' + mail + '&amp;message=' + message;
  jQuery.ajax({
      type: "POST",
      url: "sendmail.php",
      data: dataString,
      success: function () {
          alert(dataString);
          jQuery('#ok').html("&lt;h2&gt;Contact Form Submitted!&lt;/h2&gt;")
      }
  });
  return false;
  </code></pre>
  
  <p>Comment - I`m using alert to display the data string and it shows exactly my string, additionally this script always succeeds and displays "Contact Form Submitted".</p>
  
  <p>Now the sendmail.php part (I believe something is wrong in here):</p>
  
  <pre><code>// getting variables from form
  
  $emailTo = trim($_POST['address']);
  $subject = trim($_POST['title']);;
  $name = trim($_POST['name']);
  $emailFrom = trim($_POST['mail']);
  $message = $_POST['message'];
  
  // prepare email body text
  
  $Body = "You have a message from: ";
  $Body .= $name;
  $Body .= "\n";
  $Body .= "\n";
  $Body .= $message;
  
  // send prepared message
  
  $sent = mail($emailTo, $subject, $Body);
  
  //callback for jQuery AJAX
  
  if ($sent){
    echo '';
  }
  else{}
  </code></pre>
  
  <p>Any ideas? I know I'm not trimming my $message, I will, but I'm sending just one-word testing mails.</p>
  
  <p>All variables come from HTML form and are registered in jQuery script this way -  var address = $("#cmail-address").val(); . Anyways that has nothing to do with my problem since I'm getting good callback.</p>
  
  <p>And by the way my server allows to send messages and other scripts work just fine.</p>