title: wordpress wp_mail throws error: could not instantiate mail function
body: <p>I have two forms in my website. Both were working fine. but suddenly now they are not working. Emails are not going from both the forms.</p>
  
  <p>// This function gets called when user clicks on submit button</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
        var $ = jQuery;
              function sendMessage(){
              var name = $('[name="name"]').val();
              var email = $('[name="email"]').val();
              var phone = $('[name="phone"]').val();
              var message = $('[name="message"]').val();
              var filter = /^[7-9][0-9]{9}$/;
              var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  
              if(name == '')
              {
                  $('.name-error').show();
              }
              else
              {
                  $('.name-error').hide();
              }
              if(email == '')
              {
                  $('.email-error').show();
              }
              else
              {
                  $('.email-error').hide();
              }
              if(phone == '')
              {
                  $('.phone-error').show();
              }
              else
              {
                  $('.phone-error').hide();
              }
              if(message == '')
              {
                  $('.message-error').show();
              }
              else
              {
                  $('.message-error').hide();
              }
  
              if(name != '' &amp;&amp; email != '' &amp;&amp; phone != '' &amp;&amp; message != ''){
                  if(emailReg.test(email)){
                      if(filter.test(phone)){
                          var data = {
                              url:        '&lt;?php echo admin_url('admin-ajax.php');?&gt;',
                              type:       'POST',
                              action:     'send_mails',
                              formdata: $("#contact").serialize()
                          };
  
                          var myRequest = jQuery.post(data.url, data, function(response){
                              console.log(response)
                          });
  
                          myRequest.done(function(){
                              $('#msg').html("&lt;p class='msg' style='background-color:#dff0d8; border-color: #d6e9c6; color:#3c763d; padding:10px; border-radius:4px;'&gt;The Email has been sent successfully!&lt;/p&gt;").fadeIn('slow');
                              $('#msg').delay(5000).fadeOut('slow');
                          });
                          $("#contact").trigger("reset");
                          $('#msg').html("&lt;p class='msg' style='background-color:#dff0d8; border-color: #d6e9c6; color:#3c763d; padding:10px; border-radius:4px;'&gt;The Email has been sent successfully!&lt;/p&gt;").fadeIn('slow');
                              $('#msg').delay(5000).fadeOut('slow');
                      }
                      else
                      {
                          alert("Provide valid mobile number");
                      }
                  }
                  else
                  {
                      alert("Provide valid Email Id");
                  }
              }
              else
              {
                  // alert("Kindly enter all the details");
                  return false;
              }
  
          } 
      &lt;/script&gt;
  </code></pre>
  
  <p>This is function from functions.php file.</p>
  
  <pre><code>    function send_mails()
      {
          $formData = $_POST['formdata'];
          $data = array();
          parse_str($formData, $data);
  
          $name = $data['name'];
          $email = $data['email'];
          $phone = $data['phone'];
          $message = $data['message'];
  
          $msg = "A new enquiry has been posted on the website\n";
          $msg.= "Name: ".$name."\n";
          $msg.= "Email: ".$email."\n";
          $msg.= "Phone: ".$phone."\n";
          $msg.= "Message: ".$message."\n";
  
          $headers = array('Content-Type: text/html; charset=UTF-8');
  
          //echo $msg;
  
          $admin_email = get_option( 'admin_email' );
          //  print_r($admin_email);
          $res = wp_mail('email',"Enquiry",$msg,$headers);
          if($res)
          {
              echo "Mail has been sent";
  
          }
          else
          {
              echo "Could not send mail";
              debug_wpmail($res);
          }
  
          die();
      }
  
      add_action('wp_ajax_send_mails', 'send_mails');
      add_action('wp_ajax_nopriv_send_mails', 'send_mails');
  </code></pre>
  
  <p>debug_wpmail returns the error "Could not instantiate mail function". I did not find anything on google. </p>
  
  <pre><code>if ( ! function_exists('debug_wpmail') ) :
      function debug_wpmail( $result = false ) {
          if ( $result )
              return;
          global $ts_mail_errors, $phpmailer;
          if ( ! isset($ts_mail_errors) )
              $ts_mail_errors = array();
          if ( isset($phpmailer) )
              $ts_mail_errors[] = $phpmailer-&gt;ErrorInfo;
          print_r('&lt;pre&gt;');
          print_r($ts_mail_errors);
          print_r('&lt;/pre&gt;');
      }
  endif;
  </code></pre>