title: wordpress php mail send contact form to admin email
body: <p>I have built a form builder plugin. The last step is to get the emails to send to the site admin, however, I can't seem to figure out how to make this work. Here is my php mail handler:</p>
  
  <pre><code>if (!empty($errors)) {
  // if there are items in our errors array, return those errors
  $data['success'] = false;
  $data['errors'] = $errors;
  
  } else {
  parse_str($_REQUEST['formData'], $formFields);
  
  $html='&lt;html&gt;&lt;body&gt;';
  foreach ($formFields as $key =&gt; $value) {
      $html .= '&lt;p&gt;&lt;label&gt;' . $key . ' :&lt;/label&gt; ' . $value . '&lt;/p&gt;';
  }
  $html .='&lt;/body&gt;&lt;/html&gt;';
  $to = get_option('admin_email');
  $subject = "Form Submission";
  $txt = $html;
  $headers = "From: &lt;sam.skirrow@gmail.com&gt;". "\r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1"."\r\n";
  mail($to,$subject,$txt,$headers);
  
  // if there are no errors process our form, then return a message
  
  // show a message of success and provide a true success variable
  $data['success'] = true;
  $data['message'] = 'Success!';
  }
  
  // return all our data to an AJAX call
  echo json_encode($data);
  </code></pre>
  
  <p>You can see in my $to variable I have added get_option('admin_email'); however, doing this breaks my form (as opposed to just writing an email address in.</p>