WordPress wp_mail fix

Set up one authenticated SMTP plugin for WordPress wp_mail.

The safe fix is not “install every mail plugin.” Use one SMTP path, one verified From address, one test recipient, and staged tests.

Implementation checklist

  1. Choose one SMTP plugin or transactional provider.
  2. Set a domain-based From address such as `wordpress@example.com`.
  3. Use provider SMTP credentials or app password, not a WordPress admin password.
  4. Match host, port, and encryption exactly: usually 587/TLS or 465/SSL.
  5. Run a plain `wp_mail()` test before testing forms or WooCommerce.

Pattern to verify

// Pattern to verify in your environment.
add_action('admin_init', function () {
    if (!current_user_can('manage_options') || !isset($_GET['ifk_mail_test'])) {
        return;
    }

    $sent = wp_mail(
        'developer@example.com',
        'wp_mail transport test',
        'This tests whether WordPress can hand mail to the configured transport.',
        ['Content-Type: text/plain; charset=UTF-8']
    );

    wp_die($sent ? 'wp_mail returned true' : 'wp_mail returned false');
});

Common traps

  • Two SMTP plugins active at the same time.
  • Using the visitor email as the From address.
  • Testing only a form plugin while plain `wp_mail()` is still broken.