title: Custom WooCommerce Email
body: <p>After following <a href="https://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/#plugin" rel="nofollow noreferrer">this article</a>, on how to add a custom WooCommerce email, we are having problems with sending the email. </p>
  
  <p>We have custom order statuses:</p>
  
  <pre><code>wp-call-unconfirmed
  wp-call-confirmed
  </code></pre>
  
  <p>And want to send an email to the admin when any order changes from <strong>wp-call-unconfirmed</strong> to <strong>wp-call-confirmed</strong>.</p>
  
  <p>We have set up a plugin for the custom email with the following structure:</p>
  
  <pre><code>/woocommerce-call-confirmed
        /includes
            - class-wc-call-confirmed-email.php
        - woocommerce-call-confirmed-email.php
  </code></pre>
  
  <p>We have a function which changes the order status. We call the hook which triggers the email to be sent:</p>
  
  <pre><code>private function set_customer_call_verified( $order_id, $verified_status) 
  {
      // Code ommitted, changes order status from unconfirmed-&gt;confirmed 
  
      // Is this the correct way to send our custom email?
      do_action( 'woocommerce_order_status_call_unconfirmed_to_call_confirmed_notification' );
  }
  </code></pre>
  
  <p>Here are our email files:</p>
  
  <blockquote>
    <p>class-wc-call-confirmed-email.php</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  
  /**
   * A custom Call Confirmed WooCommerce Email class
   *
   * @since 0.1
   * @extends \WC_Email
   */
  class WC_Call_Confirmed_Email extends WC_Email {
  /**
       * Set email defaults
       *
       * @since 0.1
       */
      public function __construct() {
  
          // set ID, this simply needs to be a unique name
          $this-&gt;id = 'wc_call_confirmed';
  
          // this is the title in WooCommerce Email settings
          $this-&gt;title = 'Call Confirmed';
  
          // this is the description in WooCommerce email settings
          $this-&gt;description = 'Call Confirmed Notification emails are sent when a customer completes the Twilio API call';
  
          // these are the default heading and subject lines that can be overridden using the settings
          $this-&gt;heading = 'Call Confirmed';
          $this-&gt;subject = 'Call Confirmed';
  
          // these define the locations of the templates that this email should use, we'll just use the new order template since this email is similar
          $this-&gt;template_html  = 'emails/admin-new-order.php';
          $this-&gt;template_plain = 'emails/plain/admin-new-order.php';
  
          // Trigger on new paid orders
          add_action( 'woocommerce_order_status_call_unconfirmed_to_call_confirmed_notification', array( $this, 'trigger' ), 10, 2  );
  
          // Call parent constructor to load any other defaults not explicity defined here
          parent::__construct();
  
          // this sets the recipient to the settings defined below in init_form_fields()
          $this-&gt;recipient = $this-&gt;get_option( 'recipient' );
  
          // if none was entered, just use the WP admin email as a fallback
          if ( ! $this-&gt;recipient )
              $this-&gt;recipient = get_option( 'admin_email' );
      }
  
      /**
       * Determine if the email should actually be sent and setup email merge variables
       *
       * @since 0.1
       * @param int $order_id
       */
      public function trigger( $order_id ) {
  
          // bail if no order ID is present
          if ( ! $order_id )
              return;
  
          // setup order object
          $this-&gt;object = new WC_Order( $order_id );
  
          // replace variables in the subject/headings
          $this-&gt;find[] = '{order_date}';
          $this-&gt;replace[] = date_i18n( woocommerce_date_format(), strtotime( $this-&gt;object-&gt;order_date ) );
  
          $this-&gt;find[] = '{order_number}';
          $this-&gt;replace[] = $this-&gt;object-&gt;get_order_number();
  
          if ( ! $this-&gt;is_enabled() || ! $this-&gt;get_recipient() )
              return;
  
          // woohoo, send the email!
          $this-&gt;send( 'example@email.com', $this-&gt;get_subject(), $this-&gt;get_content(), $this-&gt;get_headers(), $this-&gt;get_attachments() );
      }
  
      /**
       * get_content_html function.
       *
       * @since 0.1
       * @return string
       */
      public function get_content_html() {
          ob_start();
          woocommerce_get_template( $this-&gt;template_html, array(
              'order'         =&gt; $this-&gt;object,
              'email_heading' =&gt; $this-&gt;get_heading()
          ) );
          return ob_get_clean();
      }
  
  
      /**
       * get_content_plain function.
       *
       * @since 0.1
       * @return string
       */
      public function get_content_plain() {
          ob_start();
          woocommerce_get_template( $this-&gt;template_plain, array(
              'order'         =&gt; $this-&gt;object,
              'email_heading' =&gt; $this-&gt;get_heading()
          ) );
          return ob_get_clean();
      }
  
      /**
       * Initialize Settings Form Fields
       *
       * @since 0.1
       */
      public function init_form_fields() {
  
          $this-&gt;form_fields = array(
              'enabled'    =&gt; array(
                  'title'   =&gt; 'Enable/Disable',
                  'type'    =&gt; 'checkbox',
                  'label'   =&gt; 'Enable this email notification',
                  'default' =&gt; 'yes'
              ),
              'recipient'  =&gt; array(
                  'title'       =&gt; 'Recipient(s)',
                  'type'        =&gt; 'text',
                  'description' =&gt; sprintf( 'Enter recipients (comma separated) for this email. Defaults to &lt;code&gt;%s&lt;/code&gt;.', esc_attr( get_option( 'admin_email' ) ) ),
                  'placeholder' =&gt; '',
                  'default'     =&gt; ''
              ),
              'subject'    =&gt; array(
                  'title'       =&gt; 'Subject',
                  'type'        =&gt; 'text',
                  'description' =&gt; sprintf( 'This controls the email subject line. Leave blank to use the default subject: &lt;code&gt;%s&lt;/code&gt;.', $this-&gt;subject ),
                  'placeholder' =&gt; '',
                  'default'     =&gt; ''
              ),
              'heading'    =&gt; array(
                  'title'       =&gt; 'Email Heading',
                  'type'        =&gt; 'text',
                  'description' =&gt; sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: &lt;code&gt;%s&lt;/code&gt;.' ), $this-&gt;heading ),
                  'placeholder' =&gt; '',
                  'default'     =&gt; ''
              ),
              'email_type' =&gt; array(
                  'title'       =&gt; 'Email type',
                  'type'        =&gt; 'select',
                  'description' =&gt; 'Choose which format of email to send.',
                  'default'     =&gt; 'html',
                  'class'       =&gt; 'email_type',
                  'options'     =&gt; array(
                      'plain'     =&gt; 'Plain text',
                      'html'      =&gt; 'HTML', 'woocommerce',
                      'multipart' =&gt; 'Multipart', 'woocommerce',
                  )
              )
          );
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>woocommerce-call-confirmed-email.php</p>
  </blockquote>
  
  <pre><code>  &lt;?php
  /**
   * Plugin Name: WooCommerce Custom Call Confirmed Email
   */
  
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  
  /**
   *  Add a custom email to the list of emails WooCommerce should load
   *
   * @since 0.1
   * @param array $email_classes available email classes
   * @return array filtered available email classes
   */
  function add_call_confirmed_woocommerce_email( $email_classes ) {
  
      // include our custom email class
      require( 'includes/class-wc-call-confirmed-email.php' );
  
      // add the email class to the list of email classes that WooCommerce loads
      $email_classes['WC_Call_Confirmed_Email'] = new WC_Call_Confirmed_Email();
  
      return $email_classes;
  
  }
  add_filter( 'woocommerce_email_classes', 'add_call_confirmed_woocommerce_email' );
  </code></pre>
  
  <p>However, the email is not sent. I have searched the internet for a way to do this, and cannot find why it isn't working. </p>
  
  <p>Is there anything we are missing that is preventing the email to be sent?</p>