title: How to send a custom email in the admin panel of wordpress
body: <p>Well I am trying to modify a small plugin. This plugin calculate the deposit of an item, after the user paid the deposit then the plugin send to the user an email saying that the deposit has been paid.</p>
  
  <p>I want to add a button on the admin panel in the woocommerce order that once is clicked send and email to that user saying how much left to pay. </p>
  
  <p>Firstly, I added the button:</p>
  
  <pre><code>//New action button to send the remaining email
      add_action('woocommerce_admin_order_totals_after_total', array($this, 'pay_remaining_email'));
  
    public function pay_remaining_email(){
      ?&gt;  
      &lt;tr&gt;    
          &lt;button type="button" class="button pay_remaining button-primary" title="Send"&gt;
              &lt;span&gt;Send remaining email&lt;/span&gt;
          &lt;/button&gt;
      &lt;/tr&gt;
      &lt;?php   
    }
  </code></pre>
  
  <p>Then I get this by jquery:</p>
  
  <pre><code>  /* This is will get the button from the admin panel to send the remianing email */
     $('.pay_remaining').click(function(){
          var test = 2;
          if (test =! 0){
              alert('It works');
          } else {
              alert('It isnt work');
          }
  
      });
  </code></pre>
  
  <p>Obviously this is a test, I want to call in here the function to a custom email:</p>
  
  <pre><code>&lt;?php
  
  if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
  }
  
  if ( ! class_exists( 'WC_Deposits_Email_Customer_Partially_Paid_Complete' ) ) :
  
  /**
   * Customer Partially Paid Email
   *
   * An email sent to the customer when an order is not been paid completed seven days before.
   *
   */
  class WC_Deposits_Email_Customer_Partially_Paid_Complete extends WC_Email {
  
    /**
     * Constructor
     */
    function __construct() {
  
      $this-&gt;id         = 'customer_partially_paid';
      $this-&gt;title      = __( 'Partial Payment Received', 'woocommerce-deposits' );
      $this-&gt;description    = __( 'This is an order notification sent to the customer after payment the deposit, containing order details and a link to pay the remaining balance.', 'woocommerce-deposits' );
  
      $this-&gt;heading      = __( 'Thank you for your order', 'woocommerce-deposits' );
      $this-&gt;subject        = __( 'Your {site_title} order receipt from {order_date}', 'woocommerce-deposits' );
  
      $this-&gt;template_html  = 'emails/customer-order-partially-paid.php';
      $this-&gt;template_plain   = 'emails/plain/customer-order-partially-paid.php';
  
      // Triggers for this email
      add_action( 'pay_remaining_email', array( $this, 'trigger' ) );
  
  
      // Call parent constructor
      parent::__construct();
  
      $this-&gt;template_base = WC_DEPOSITS_TEMPLATE_PATH;
    }
  
    /**
     * trigger function.
     *
     * @access public
     * @return void
     */
    function trigger( $order_id ) {
  
      if ( $order_id ) {
        $this-&gt;object     = wc_get_order( $order_id );
        $this-&gt;recipient  = $this-&gt;object-&gt;billing_email;
  
        $this-&gt;find['order-date']      = '{order_date}';
        $this-&gt;find['order-number']    = '{order_number}';
  
        $this-&gt;replace['order-date']   = date_i18n( wc_date_format(), strtotime( $this-&gt;object-&gt;order_date ) );
        $this-&gt;replace['order-number'] = $this-&gt;object-&gt;get_order_number();
      }
  
      if ( ! $this-&gt;is_enabled() || ! $this-&gt;get_recipient() ) {
        return;
      }
  
      $this-&gt;send( $this-&gt;get_recipient(), $this-&gt;get_subject(), $this-&gt;get_content(), $this-&gt;get_headers(), $this-&gt;get_attachments() );
    }
  
    /**
     * get_content_html function.
     *
     * @access public
     * @return string
     */
    function get_content_html() {
      ob_start();
      wc_get_template( $this-&gt;template_html, array(
        'order'     =&gt; $this-&gt;object,
        'email_heading' =&gt; $this-&gt;get_heading(),
        'sent_to_admin' =&gt; false,
        'plain_text'    =&gt; false
      ), '', $this-&gt;template_base );
      return ob_get_clean();
    }
  
    /**
     * get_content_plain function.
     *
     * @access public
     * @return string
     */
    function get_content_plain() {
      ob_start();
      wc_get_template( $this-&gt;template_plain, array(
        'order'         =&gt; $this-&gt;object,
        'email_heading' =&gt; $this-&gt;get_heading(),
        'sent_to_admin' =&gt; false,
        'plain_text'    =&gt; true
      ), '', $this-&gt;template_base );
      return ob_get_clean();
    }
  }
  
  endif;
  
  return new WC_Deposits_Email_Customer_Partially_Paid_Complete();
  </code></pre>
  
  <p>Any ideas how can I accomplish this?</p>