public static function preview_wp_email_template() { check_ajax_referer( 'preview_wp_email_template', 'security' ); $email_heading = __('Email preview', 'wp_email_template'); echo WP_Email_Template_Hook_Filter::preview_wp_email_content( $email_heading ); die(); }
public function send_a_test_email( $to_email ) { global $phpmailer; if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer( true ); } // Set SMTPDebug to true //$phpmailer->SMTPDebug = true; $email_heading = __('Email preview', 'wp_email_template'); $message = WP_Email_Template_Hook_Filter::preview_wp_email_content( $email_heading ); $result = wp_mail( $to_email, $email_heading, $message ); echo $this->mandrill_send_email_error_notice(); if ( ! $result ) { ob_start(); $phpmailer->Body = ''; //$phpmailer->MIMEBody = null; var_dump( $phpmailer ); $phpmailer_error = ob_get_clean(); $phpmailer_error = str_replace( 'body {', 'body_replace', $phpmailer_error ); add_thickbox(); echo '<div id="test_error_container" style="display:none;"><p><pre>'. $phpmailer_error . '</pre></p></div>'; } // Destroy $phpmailer so it doesn't cause issues later unset($phpmailer); return $result; }