I'm attempting to configure a plugin that sends an email to the customer after they place or complete an order. The plugin should send a custom email after a specified time, but for some reason, the email is neither sent nor received. i wrote coded some input and addtionnal checks in place so i confirm eveything in place , other email like order procced the sutomer recieve them normally without any problem at all I'm trying to set up a plugin that should send a custom email to the customer after they place or complete an order. However, I've encountered an issue where the email is not being sent or received as expected. I've added some input and additional checks to ensure that everything is in place, and other emails such as order confirmations are being received by the customer without any issues. public function schedule_review_email($order_id, $old_status, $new_status) { $settings = get_option('fast_reviews_settings'); if (!$settings || empty($settings['trigger_status']) || empty($settings['send_after_value']) || empty($settings['send_after_unit'])) { error_log("Fast Reviews settings are not properly configured."); return; } error_log("schedule_review_email triggered for Order ID: $order_id, Old Status: $old_status, New Status: $new_status"); if ($new_status === $settings['trigger_status']) { $delay = intval($settings['send_after_value']); $unit = sanitize_text_field($settings['send_after_unit']); $valid_units = ['seconds', 'minutes', 'hours', 'days']; if (!in_array($unit, $valid_units)) { error_log("Invalid time unit provided: $unit"); return; } $unit_multiplier = $unit === 'seconds' ? 1 : ($unit === 'minutes' ? 60 : ($unit === 'hours' ? 3600 : 86400)); $schedule_timestamp = time() + $delay * $unit_multiplier; error_log("Scheduling email for Order ID: $order_id to be sent after $delay $unit at timestamp: $schedule_timestamp"); wp_clear_scheduled_hook('fast_reviews_send_email', [$order_id]); wp_schedule_single_event($schedule_timestamp, 'fast_reviews_send_email', [$order_id]); } else { error_log("No action taken for Order ID: $order_id. New status does not match trigger status."); } } public function send_review_email($order_id) { $order = wc_get_order($order_id); if (!$order) { error_log("Order not found for Order ID: $order_id"); return; } $customer_name = $order->get_billing_first_name(); $order_number = $order->get_order_number(); $customer_email = $order->get_billing_email(); if (empty($customer_email)) { error_log("No billing email found for Order ID: $order_id"); return; } error_log("Preparing to send review email for Order ID: $order_id, Customer Name: $customer_name, Order Number: $order_number"); // Retrieve email settings $settings = get_option('fast_reviews_settings'); if (!$settings) { error_log("Fast Reviews settings not found."); return; } $review_url = isset($settings['review_url']) ? esc_url($settings['review_url']) : ''; $trustpilot_url = isset($settings['trustpilot_url']) ? esc_url($settings['trustpilot_url']) : ''; $subject = isset($settings['email_subject']) ? sanitize_text_field($settings['email_subject']) : 'Review Request'; $content = isset($settings['email_content']) ? str_replace( ['{customer_name}', '{order_number}', '{review_url}', '{trustpilot_url}'], [$customer_name, $order_number, $review_url, $trustpilot_url], wpautop($settings['email_content']) // Convert line breaks to HTML <p> tags ) : ''; $headers = [ 'Content-Type: text/html; charset=UTF-8', 'From: Your Company Name <noreply@yourdomain.com>', // Customize From address 'Reply-To: support@yourdomain.com' // Customize Reply-To address ]; $max_attempts = 3; $sent = false; for ($attempts = 1; $attempts <= $max_attempts; $attempts++) { error_log("Attempt $attempts: Sending email to: $customer_email, Subject: $subject"); $sent = wp_mail($customer_email, $subject, $content, $headers); if ($sent) { error_log("Email sent successfully to: $customer_email"); break; } else { error_log("Attempt $attempts: Failed to send email to: $customer_email"); if ($attempts < $max_attempts) { sleep(5); } } }