title: PHP Mail with Recaptcha 2.0
body: <p>I'm trying to get this email form to work using php but Im unfortunately not able to. What happens is that when I press submit, its just processing and chrome says "Waiting for localhost".</p>
  
  <p>Some background: I am using WAMP locally and edited php.ini with gmail's smtp server with port 465.I am using the default mail function but I'm kind doubtful of it and think that since google needs authentication and so on I need to use libraries like sendmail. Having that said, I am just trying to send an email in core and dont care what library to use.</p>
  
  <p>HTML Form:</p>
  
  <pre><code>&lt;div id="email"&gt;
                              &lt;div class="email-icon center"&gt;
                                  &lt;i class="fa fa-envelope-o fa-5x"&gt;&lt;/i&gt;
                              &lt;/div&gt;
                              &lt;form id="contact" method="POST" action="sendmail.php"&gt;
                                  &lt;div class="input-group"&gt;
                                      &lt;span class="input-group-addon"&gt;
                                          &lt;i class="fa fa-pencil"&gt;&lt;/i&gt;
                                      &lt;/span&gt;
                                      &lt;input type="text" name="name" id="name" class="form-control" placeholder="Name" required&gt;
                                  &lt;/div&gt;
                                  &lt;div class="input-group"&gt;
                                      &lt;span class="input-group-addon"&gt;
                                          &lt;i class="fa fa-pencil"&gt;&lt;/i&gt;
                                      &lt;/span&gt;
                                      &lt;input type="text" name="email" class="form-control" placeholder="Email" required&gt;
                                  &lt;/div&gt;
                                  &lt;div class="input-group"&gt;
                                      &lt;span class="input-group-addon"&gt;
                                          &lt;i class="fa fa-pencil"&gt;&lt;/i&gt;
                                      &lt;/span&gt;
                                      &lt;input type="text" name="subject" class="form-control" placeholder="Subject" required&gt;
                                  &lt;/div&gt;
                                  &lt;div class="input-group"&gt;
                                      &lt;span class="input-group-addon"&gt;
                                          &lt;i class="fa fa-pencil"&gt;&lt;/i&gt;
                                      &lt;/span&gt;
                                      &lt;textarea name="message" class="form-control status-box" id="message" rows="4" placeholder="What's on your mind?" required&gt;&lt;/textarea&gt;
                                  &lt;/div&gt;
                                  &lt;div class="g-recaptcha" data-sitekey="6LdQ6wgTAAAAAHOj3FnhjZF6FMmUCC_r4FMdx2m2" data-theme="dark"&gt;&lt;/div&gt;
                                  &lt;div class="input-group"&gt;
                                      &lt;div class="container"&gt;
                                          &lt;div class="row"&gt;
                                              &lt;div class="col-md-4 col-md-offset-4 center"&gt;
                                                  &lt;span class="input-group-button"&gt;
                                                      &lt;button class="btn btn-default" name="submit" type="submit" value="Submit"&gt; SEND &lt;/button&gt; 
                                                  &lt;/span&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/form&gt;
                              &lt;div class="response center"&gt;&lt;/div&gt;
                          &lt;/div&gt;
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>&lt;?php
      require ("src/autoload.php");
  
      $name = $_POST["name"];
      $email = $_POST["email"];
      $subject = trim($_POST["subject"]);
      $message = $_POST["message"];
      $to = "example@gmail.com";
      $headers = "From: ".$email."\r\n";
  
      $secret = "MY SECRET CODE";
      $recaptcha = new \ReCaptcha\ReCaptcha($secret);
      $resp = $recaptcha-&gt;verify($_POST["g-recaptcha-response"], $_SERVER["REMOTE_ADDR"]);
      if (!$resp-&gt;isSuccess()) {
          $captchaErr = "The reCAPTCHA wasn't entered correctly. Please try it again.";
      } 
      else {
          $validCaptcha = true;
      }
  
      if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
          $emailErr = "Invalid email format";
      }
      else{
          $validEmail = true;
      }
  
      if ( $validCaptcha &amp;&amp; $validEmail) {
          $sendMail = mail($to, $subject, $message, $headers);
      }
  
      if ($sendMail) {
          $sendMailSucc = "";
      } 
      else {
          $sendMailErr = "";
      }
  ?&gt;
  </code></pre>
  
  <p>PHP.INI Mail function</p>
  
  <pre><code>[mail function]
  ; For Win32 only.
  ; http://php.net/smtp
  SMTP = smtp.gmail.com
  ; http://php.net/smtp-port
  smtp_port = 465
  
  ; For Win32 only.
  ; http://php.net/sendmail-from
  sendmail_from = example@gmail.com
  
  ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
  ; http://php.net/sendmail-path
  ;sendmail_path = 
  
  ; Force the addition of the specified parameters to be passed as extra parameters
  ; to the sendmail binary. These parameters will always replace the value of
  ; the 5th parameter to mail(), even in safe mode.
  ;mail.force_extra_parameters =
  
  ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
  mail.add_x_header = On
  
  ; The path to a log file that will log all mail() calls. Log entries include
  ; the full path of the script, line number, To address and headers.
  ;mail.log =
  ; Log mail to syslog (Event Log on NT, not valid in Windows 95).
  ;mail.log = syslog
  </code></pre>
  
  <p>Also a note, I dont know why, but the PHP-smtp extension of WAMP has a danger sign and I think that can cause problems too. </p>
  
  <p>I would appreciate any help. I would also appreciate it if someone could let me know how I can make this happen without opening a new page and send the email in-place.</p>