title: Does the php mail() function work in Wordpress?
body: <p>This relates to another question I posted here but it's a 
  different matter so I hope people don't think I'm double posting.</p>
  
  <p>I have an email form in Wordpress like this.</p>
  
  <p>html</p>
  
  <pre><code>    &lt;form action="" id="contactForm"&gt;
          &lt;input type="text" id="contactName" placeholder="Name:"&gt;
          &lt;input type="text" id="contactEmail" placeholder="Email:"&gt;
          &lt;select id="form-subject"&gt;
            &lt;option&gt;Subject&lt;/option&gt;
            &lt;option&gt;Accounts&lt;/option&gt;
            &lt;option&gt;Bookkeeping&lt;/option&gt;
            &lt;option&gt;Start Up&lt;/option&gt;
            &lt;option&gt;CIS Returns&lt;/option&gt;
            &lt;option&gt;Payroll&lt;/option&gt;
            &lt;option&gt;Self Assessment&lt;/option&gt;
            &lt;option&gt;Tax Returns&lt;/option&gt;
            &lt;option&gt;VAT Returns&lt;/option&gt;
                          &lt;option&gt;Other&lt;/option&gt;
          &lt;/select&gt;  
          &lt;textarea id="contactMessage" rows="8" cols="40" placeholder="Message:"&gt;&lt;/textarea&gt;
                      &lt;p id="submit"&gt;Submit&lt;/p&gt;
                      &lt;div id="status"&gt;
            &lt;p&gt;&lt;/p&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>jquery</p>
  
  <pre><code>    $j('#submit').click(function(){     
          //
          var nameVal = $j('#contactForm #contactName').val();
          var emailVal = $j('#contactForm #contactEmail').val();
          var messageVal = $j('#contactForm #contactMessage').val();
  
          //
          $j.post('wp-content/code/contactEngine.php', { theName:nameVal, theEmail:emailVal, theMessage:messageVal }, function(data){
              $j("#status p").html(data);
              $j("#status p").show().fadeOut(3500);
              if(data.indexOf('Thank You')==0) {document.forms[0].reset();}
          });
      })
  </code></pre>
  
  <p>php</p>
  
  <pre><code>    &lt;?php
  
        $errors = array();
        $required_fields = array('theName','theEmail','theMessage');
        foreach($required_fields as $fieldname){
           if(!isset($_POST[$fieldname]) || empty($_POST[$fieldname])){
              $errors[] = $fieldname;
           }
        }
        if(empty($errors)){
           $name_field = Trim(stripslashes($_POST['theName']));
           $name = explode(' ', $name_field);
           $firstname = ucfirst($name[0]);
           $email_field = Trim(stripslashes($_POST['theEmail']));
           $message = Trim(stripslashes($_POST['theMessage']));
           //
           $to = "info@ttmt.org.uk";
           $subject = "Email from Website";
           $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
           //
           mail($to, $subject, $body);
  
               //wp_mail($to, $subject, $body);   
  
           echo "Thank You $firstname";
        }else{
           echo "Please complete all fields.";
        }
  
      ?&gt;
  </code></pre>
  
  <p>The php is in a folder in the wp-content folder so it's easy for the jquery to access it.</p>
  
  <pre><code>$j.post('wp-content/code/contactEngine.php', { theName:nameVal, theEmail:emailVal, theMessage:messageVal }, function(data){ 
  </code></pre>
  
  <p>The variables reach the php and echo back a reply if the form is complete or not.   </p>
  
  <p>The actual email isn't sent - Does the php mail() function work in Worpdress.</p>
  
  <p>I tried the wp_mail() function but this stops the script completely and I don't get the echo.</p>
  
  <p>I know there are email plugins like Contact Form 7 but I don't think they will work with this site.</p>
  
  <p>It's a single page site with a Custom Post Type, I'm not calling any content, which I think I ned to do with Contact Form 7.</p>