title: sending email with admin-ajax.php in wordpress not working when modification of a plugin
body: <p>i am trying to modify a wordpress plugin to add email sending functionality using admin-ajax.php, my code in my_plugin.php like below:</p>
  
  <pre><code>add_action( 'wp_ajax_nopriv_send_email', 'send_email' ); 
  add_action( 'wp_ajax_send_email', 'send_email' );
  
  function send_email(){
      echo "send email"; die(); //it could not printed
      if ( count($_POST) &gt; 0 ){
           $to = $_REQUEST['to'];
           $from = $_REQUEST['from'];
           $sub = $_REQUEST['subject'];
           $msg = $_REQUEST['msg'];
  
          $headers = 'From: myname &lt;myemail@wordpress.com&gt;' . "\r\n";
          wp_mail( $to, $sub, $msg, $headers);
          exit;
      }
      exit;
  
  }
  </code></pre>
  
  <p>and in my form.php</p>
  
  <pre><code>jQuery.ajax({
              type: 'POST',
              url: '".admin_url('admin-ajax.php')."',  
              action:'send_email',
              data: { to:'reciever@gmail.com',
                      from: 'sender@gmail.com',
                      subject: 'test',
                      msg: 'thank you'
                      },
              success: function (res) {
                       alert('The server responded: ' + res);
                  }
  
          });
  </code></pre>
  
  <p>problem is that when i post the request it can't enter in to the send_email() function and not sending any email but it always responded 0 and throw a success message alert like 'The Server responded: 0' ; what's wrong i am doing here? i am stuck at here..</p>