/**
 * Sends a test email
 *
 * @since 1.0.0
 */
function bp_send_test_email()
{
    if (isset($_GET['send_bp_test_email'])) {
        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'send-test-email')) {
            wp_die('Security check');
        }
        // Get current user
        $current_user = wp_get_current_user();
        // Send test email to current user
        $send_to = $current_user->user_email;
        // Load the mailer class
        $mailer = Welcome_Buddy::mailer();
        $email_heading = __('Email Preview', 'welcome-buddy');
        ob_start();
        include_once 'views/html-email-template-preview.php';
        $message = ob_get_clean();
        $email = new BP_Email();
        // Wrap the content with the email template and then add styles
        $message = $email->style_inline($mailer->wrap_message($email_heading, $message));
        $subject = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES) . ' ' . __('Test Email', 'welcome-buddy');
        if ($email->send($send_to, $subject, $message)) {
            _e('Test email was sent', 'welcome-buddy');
        } else {
            _e('Test email was not sent', 'welcome-buddy');
        }
        exit;
    }
}