Email Flow Diagnostic Tool

1. System Status

✓ ENABLED' : '✗ DISABLED'; echo "
$status - Notification System Mode: $system_mode
"; // Check email channel $email_enabled = get_option('woonoow_email_notifications_enabled', false); $status = $email_enabled ? '✓ ENABLED' : '✗ DISABLED'; echo "
$status - Email Channel: " . ($email_enabled ? 'enabled' : 'disabled') . "
"; // Check Action Scheduler $as_exists = function_exists('as_enqueue_async_action'); $status = $as_exists ? '✓ AVAILABLE' : '⚠ NOT AVAILABLE'; echo "
$status - Action Scheduler: " . ($as_exists ? 'available' : 'not available (using wp-cron)') . "
"; ?>

2. Event Configuration

✗ FAIL - No events configured!"; } else { echo "
✓ PASS - " . count($events) . " events configured
"; echo "
";
        foreach ($events as $event_id => $event_data) {
            $email_enabled = $event_data['channels']['email']['enabled'] ?? false;
            $status_icon = $email_enabled ? '✓' : '✗';
            echo "$status_icon $event_id: email " . ($email_enabled ? 'enabled' : 'disabled') . "\n";
        }
        echo "
"; } ?>

3. Email Queue Status

get_results( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE 'woonoow_mail_%' LIMIT 10" ); if (empty($queued_emails)) { echo "
⚠ INFO - No emails currently queued
"; } else { echo "
✓ INFO - " . count($queued_emails) . " emails in queue
"; echo "
";
        foreach ($queued_emails as $email) {
            $payload = maybe_unserialize($email->option_value);
            echo "ID: {$email->option_name}\n";
            echo "To: " . ($payload['to'] ?? 'unknown') . "\n";
            echo "Subject: " . ($payload['subject'] ?? 'unknown') . "\n";
            echo "---\n";
        }
        echo "
"; } ?>

4. Action Scheduler Queue

get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'pending'" ); $failed = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'failed'" ); $complete = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'complete' ORDER BY action_id DESC LIMIT 10" ); echo "
✓ INFO - Pending: $pending
"; echo "
✓ INFO - Completed (last 10): $complete
"; if ($failed > 0) { echo "
✗ WARN - Failed: $failed
"; // Show failed actions $failed_actions = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'failed' ORDER BY action_id DESC LIMIT 5" ); if ($failed_actions) { echo "
Recent failures:\n";
                foreach ($failed_actions as $action) {
                    echo "ID: {$action->action_id}\n";
                    echo "Args: {$action->args}\n";
                    echo "Scheduled: {$action->scheduled_date_gmt}\n";
                    echo "---\n";
                }
                echo "
"; } } else { echo "
✓ PASS - Failed: 0
"; } } else { echo "
⚠ WARN - Action Scheduler not available, using wp-cron
"; } ?>

5. Recent Email Logs

⚠ INFO - No email logs found (enable WP_DEBUG to see logs)"; } else { echo "
✓ INFO - " . count($email_logs) . " email log entries found
"; echo "
";
            echo implode('', array_slice($email_logs, -10)); // Last 10 entries
            echo "
"; } } else { echo "
⚠ INFO - Debug log not found (enable WP_DEBUG_LOG)
"; } ?>

6. Test Actions

"; if ($_GET['action'] === 'test_email') { echo "

Testing Email Queue...

"; // Queue a test email $test_payload = [ 'to' => get_option('admin_email'), 'subject' => 'WooNooW Test Email - ' . date('Y-m-d H:i:s'), 'html' => '

Test Email

This is a test email from WooNooW email queue system.

Time: ' . date('Y-m-d H:i:s') . '

', 'headers' => ['Content-Type: text/html; charset=UTF-8'], 'attachments' => [], ]; \WooNooW\Core\Mail\MailQueue::enqueue($test_payload); echo "

✓ SUCCESS - Test email queued to: " . get_option('admin_email') . "

"; echo "

Check your inbox in a few moments. Also check Action Scheduler queue above.

"; } if ($_GET['action'] === 'process_queue') { echo "

Processing Email Queue...

"; if (function_exists('as_run_queue')) { as_run_queue(); echo "

✓ SUCCESS - Action Scheduler queue processed

"; } else { echo "

⚠ WARN - Action Scheduler not available

"; } } if ($_GET['action'] === 'test_order_email') { echo "

Testing Order Email...

"; // Get a recent order $orders = wc_get_orders(['limit' => 1, 'orderby' => 'date', 'order' => 'DESC']); if (empty($orders)) { echo "

✗ FAIL - No orders found. Create a test order first.

"; } else { $order = $orders[0]; echo "

Using order #" . $order->get_id() . "

"; // Trigger order processing email $email_manager = \WooNooW\Core\Notifications\EmailManager::instance(); $email_manager->send_order_processing_email($order->get_id(), $order); echo "

✓ SUCCESS - Order processing email triggered

"; echo "

Check Action Scheduler queue and email logs above.

"; } } echo ""; } ?>

7. Troubleshooting

If emails are not sending:

  1. Check that "Notification System Mode" is set to "woonoow" (not "woocommerce")
  2. Check that "Email Channel" is enabled
  3. Check that specific events have email enabled in configuration
  4. Check Action Scheduler for failed actions
  5. Enable WP_DEBUG and WP_DEBUG_LOG to see detailed logs
  6. Check your server's mail configuration (SMTP, sendmail, etc.)
  7. Test with "Queue Test Email" button above
Generated: