'WP Mail SMTP', 'fluent-smtp/fluent-smtp.php' => 'FluentSMTP', 'post-smtp/postman-smtp.php' => 'Post SMTP', 'easy-wp-smtp/easy-wp-smtp.php' => 'Easy WP SMTP', 'gmail-smtp/main.php' => 'Gmail SMTP', 'wp-ses/wp-ses.php' => 'WP Offload SES', 'sendgrid-email-delivery-simplified/wpsendgrid.php' => 'SendGrid', ]; $found = []; if (!function_exists('is_plugin_active')) require_once ABSPATH . 'wp-admin/includes/plugin.php'; foreach ($smtp_plugins as $file => $label) { if (is_plugin_active($file)) $found[] = $label; } $f[] = $this->finding( 'mailer', $found ? 'ok' : 'info', 'Mailer', $found ? implode(', ', $found) : 'PHP mail() (default)', $found ? 'Test will route through this plugin.' : 'No SMTP plugin detected — wp_mail will use PHP\'s built-in mail() function, which is often blocked on shared hosts.' ); // Default From address (filter into wp_mail_from) $from = apply_filters('wp_mail_from', ''); if (!$from) { $sitename = parse_url(get_site_url(), PHP_URL_HOST) ?: 'localhost'; $sitename = preg_replace('/^www\./', '', strtolower($sitename)); $from = 'wordpress@' . $sitename; } $f[] = $this->finding('from_address', 'info', 'Default From', $from, 'wp_mail_from filter value.'); return $f; } /** Render the send-test form inside the step card. */ public function render_extra(array $session_state): void { $current = wp_get_current_user(); $default_to = $current && $current->user_email ? $current->user_email : get_option('admin_email'); ?>

Send test email

Uses wp_mail() with the default From address. Result is appended to the findings above.

finding('last_send', 'bad', 'Last test send', 'invalid address', 'The destination address was not a valid email.'); } // Capture any wp_mail_failed error so we can surface the underlying reason. $error_msg = ''; $capture = function ($wp_error) use (&$error_msg) { if (is_object($wp_error) && method_exists($wp_error, 'get_error_message')) { $error_msg = (string) $wp_error->get_error_message(); } }; add_action('wp_mail_failed', $capture); $host = parse_url(get_site_url(), PHP_URL_HOST) ?: 'site'; $subject = '[Site Healthcheck] Test from ' . $host . ' — ' . date('Y-m-d H:i'); $body = "This is a test email sent from the Site Healthcheck plugin.\n\n" . "Site: " . get_site_url() . "\n" . "Sent: " . date('Y-m-d H:i:s') . "\n" . "Technician: " . (wp_get_current_user()->user_login ?? '?') . "\n\n" . "If you received this, wp_mail() is working from this site."; $sent = wp_mail($to, $subject, $body); remove_action('wp_mail_failed', $capture); $time = date('Y-m-d H:i'); if ($sent) { return $this->finding( 'last_send', 'ok', 'Last test send', 'sent to ' . $to . ' at ' . $time, 'wp_mail() returned true. Confirm receipt in the inbox (check spam too).' ); } return $this->finding( 'last_send', 'bad', 'Last test send', 'failed at ' . $time, $error_msg ?: 'wp_mail() returned false but no error was captured. Check the host\'s mail logs.' ); } };