Use WP_mail for Woocommerce mails

Use WP_mail for Woocommerce mails

follow site Buy Viagra 25 mg in Lancaster California This blog describes how this can be done


Code from Justin Silver:

// Determine if it's an email using the WooCommerce email header
add_action( 'woocommerce_email_header', function(){ add_filter( "better_wc_email", "__return_true" ); } );
 
// Hide the WooCommerce Email header and footer
add_action( 'woocommerce_email_header', function(){ ob_start(); }, 1 );
add_action( 'woocommerce_email_header', function(){ ob_get_clean(); }, 100 );
add_action( 'woocommerce_email_footer', function(){ ob_start(); }, 1 );
add_action( 'woocommerce_email_footer', function(){ ob_get_clean(); }, 100 );
 
// Selectively apply WPBE template if it's a WooCommerce email
add_action( 'phpmailer_init', 'better_phpmailer_init', 20 );
function better_phpmailer_init( $phpmailer ){
    if ( apply_filters( 'better_wc_email', false ) ){
        global $wp_better_emails;
 
        // Add template to message
        $phpmailer->Body = $wp_better_emails->set_email_template( $phpmailer->Body );
 
        // Replace variables in email
        $phpmailer->Body = apply_filters( 'wpbe_html_body', $wp_better_emails->template_vars_replacement( $phpmailer->Body ) );
    }