title: angularJs and PHP send email form
body: <p>I want to send an email with the form parameters, with AngularJs and PHP, the email is sending but the parameters (name, email, etc) are empty. Where is the mistake?
  I'm pretty new to AngularJS and trying to build a contact form. I did some research to validate with angular, this works fine. However sending the input to my email account is still a mystery.</p>
  <p>HMTl Code:</p>
  <pre><code>&lt;form id=&quot;myform&quot; name=&quot;myForm&quot; data-abide role=&quot;form&quot; ng-submit=&quot;processForm()&quot;&gt;
              &lt;div class=&quot;formData.name&quot;&gt;
                  &lt;label&gt;Your name &lt;small&gt;required&lt;/small&gt;
                      &lt;input type=&quot;text&quot; name=&quot;formData.name&quot; id=&quot;formData.name&quot; required pattern=&quot;[a-zA-Z]+&quot; ng-model=&quot;formData.name&quot;&gt;
                  &lt;/label&gt;
                  &lt;small class=&quot;error&quot;&gt;Name is required.&lt;/small&gt;
              &lt;/div&gt;
  
              &lt;div class=&quot;formData.name&quot;&gt;
                  &lt;label&gt;Your subject &lt;small&gt;required&lt;/small&gt;
                      &lt;input type=&quot;text&quot; name=&quot;formData.subject&quot; id=&quot;formData.subject&quot; required pattern=&quot;[a-zA-Z]+&quot; ng-model=&quot;formData.subject&quot;&gt;
                  &lt;/label&gt;
                  &lt;small class=&quot;error&quot;&gt;subject is required.&lt;/small&gt;
              &lt;/div&gt;
  
              &lt;div class=&quot;formData.inputEmail-field&quot;&gt;
                  &lt;label&gt;Email &lt;small&gt;required&lt;/small&gt;
                      &lt;input type=&quot;email&quot; name=&quot;formData.email&quot; id=&quot;formData.email&quot; required ng-model=&quot;formData.email&quot;&gt;
                  &lt;/label&gt;
                  &lt;small class=&quot;error&quot;&gt;An email address is required.&lt;/small&gt;
              &lt;/div&gt;
  
              &lt;div class=&quot;formData.tel&quot;&gt;
                  &lt;label&gt;Phone #
                      &lt;input type=&quot;text&quot; name=&quot;formData.tel&quot; id=&quot;formData.tel&quot;required pattern=&quot;^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$&quot; ng-model=&quot;formData.tel&quot;&gt;
                  &lt;/label&gt;
                  &lt;small class=&quot;error&quot;&gt;Please enter your number in the format '123-456-7890'.&lt;/small&gt;
              &lt;/div&gt;
              &lt;div class=&quot;formData.message&quot;&gt;
                  &lt;label&gt;Message
                      &lt;textarea name=&quot;formData.message&quot; id=&quot;formData.message&quot; ng-model=&quot;formData.message&quot;&gt;&lt;/textarea&gt; &lt;/label&gt;&lt;/div&gt;
                      &lt;button type=&quot;submit&quot; class=&quot;columns small-centered&quot;&gt;Submit&lt;/button&gt;
                      &lt;div class=&quot;panel&quot;&gt;
                          &lt;p&gt;{{formData}}&lt;/p&gt;
                          &lt;p&gt;{{codeStatus}}&lt;/p&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
  </code></pre>
  <p>Code in my controller:</p>
  <pre><code>$scope.processForm = function() {
        $http({
          method  : 'POST',
          url     : 'process.php',
          data    : $.param($scope.formData), 
          headers : { 'Content-Type': 'application/x-www-form-urlencoded' },
        }).success(function(formData) {
          console.log(formData);
          if (formData.success) {
            console.log('Success');
          } else {
  
            console.log('Fail');
          }
        });
      };
  </code></pre>
  <p>PHP Code:</p>
  <pre><code>&lt;?php
  
  $postdata = file_get_contents(&quot;php://input&quot;);
  if(!isset($postdata)) {
      $response = array('status' =&gt; 'error', 'value'=&gt;'Eroare de server - 0.');
      die(json_encode($response));
  }
  $request = json_decode($postdata);
  
  $name = htmlspecialchars($request-&gt;name);
  $tel = htmlspecialchars($request-&gt;tel);
  $email = htmlspecialchars($request-&gt;email);
  $subject = htmlspecialchars($request-&gt;subject);
  $mess = htmlspecialchars($request-&gt;message);
  
  $to = &quot;cristina@yahoo.com&quot;;
  $subject = $subject;
  
  $message = &quot;The user: $name contacted you using the contact form. His details are:\r\nPhone: $tel\r\nEmail: $email\r\nMessage: $mess&quot;;
  
  $headers = &quot;From: &lt;&quot;.$email.&quot;&gt;&quot;. &quot;\r\n&quot;;
  $headers .= &quot;Reply-To: &lt;&quot;.$email.&quot;&gt;&quot;. &quot;\r\n&quot;;
  $headers .= 'MIME-Version: 1.0'. &quot;\r\n&quot;;
  $headers .= 'Content-type: text/html; charset=UTF-8'. &quot;\r\n&quot;;
  if(mail($to, $subject, $message, $headers)) {
      $response = array('status' =&gt; 'success', 'value'=&gt;'Mail trimis');
      echo json_encode($response);
  } else {
      $response = array('status' =&gt; 'error', 'value'=&gt;'Mail netrimis');
      die(json_encode($response));
  }
  ?&gt;
  </code></pre>