MailOdds

WordPress + MailOdds

Official WordPress plugin for email validation on registration, WooCommerce checkout, WPForms, Gravity Forms, and Contact Form 7. Includes admin dashboard, bulk validation, and WP-CLI.

Setup time: 2-5 min
Difficulty: Beginner
1,000 free validations included

Prerequisites

  • MailOdds account with API key
  • WordPress 5.9+ with admin access

MailOdds WordPress Plugin

Install the plugin for automatic email validation with zero code. Includes settings page, form integrations, bulk validation, dashboard widget, and WP-CLI commands.

Plugin Features

Form Validation

  • - WordPress core registration
  • - WooCommerce registration + checkout
  • - WPForms, Gravity Forms, Contact Form 7
  • - Configurable block threshold
  • - Fail-open on API timeout

Admin Tools

  • - Settings page (API key, depth, threshold)
  • - Dashboard widget with 7-day stats
  • - Bulk user validation tool
  • - Test mode with badge indicator
  • - Policy support

Performance

  • - 24h transient cache per email
  • - Batch API calls for bulk operations
  • - Lightweight (no external dependencies)
  • - Assets loaded only on plugin pages

Automation

  • - WP-CLI: validate, bulk, status
  • - Weekly cron for unvalidated users
  • - Per-user validation metadata
  • - Clean uninstall (removes all data)

Quick Setup (Plugin)

PHP
// 1. Upload the 'mailodds' folder to /wp-content/plugins/
// 2. Activate via Plugins menu
// 3. Go to Settings > MailOdds and enter your API key
// 4. Enable the form integrations you need:
//    - WordPress Registration
//    - WooCommerce (registration + checkout)
//    - WPForms
//    - Gravity Forms
//    - Contact Form 7

// That's it! The plugin handles caching, timeouts, and error handling.

Alternative: Manual PHP Integration

If you prefer not to install the plugin, add these snippets to your theme's functions.php or a custom plugin. Define MAILODDS_API_KEY in wp-config.php.

PHP: Registration Validation (with caching)

PHP
// functions.php - Manual integration (if not using the plugin)
// Validates email on registration with caching and fail-open timeout

add_action('registration_errors', function($errors, $sanitized_user_login, $user_email) {
    // Skip if API key not defined
    if (!defined('MAILODDS_API_KEY')) {
        return $errors;
    }

    // Check transient cache (24h TTL)
    $cache_key = 'mailodds_' . substr(hash('sha256', strtolower($user_email)), 0, 16);
    $cached = get_transient($cache_key);

    if (false === $cached) {
        $response = wp_remote_post('https://api.mailodds.com/v1/validate', [
            'headers' => [
                'Authorization' => 'Bearer ' . MAILODDS_API_KEY,
                'Content-Type'  => 'application/json',
            ],
            'body'    => json_encode(['email' => $user_email]),
            'timeout' => 5,
        ]);

        // Fail-open: if API unreachable, allow registration
        if (is_wp_error($response)) {
            return $errors;
        }

        $cached = json_decode(wp_remote_retrieve_body($response), true);
        if (isset($cached['result'])) {
            $cached = $cached['result'];
        }

        // Cache for 24 hours
        set_transient($cache_key, $cached, DAY_IN_SECONDS);
    }

    $action = isset($cached['action']) ? $cached['action'] : '';

    if ('reject' === $action) {
        $errors->add('invalid_email',
            'Error: This email address could not be verified.');
    }

    return $errors;
}, 10, 3);

PHP: WooCommerce Checkout Validation

PHP
// WooCommerce checkout validation (included in the plugin)
// Also validates on WooCommerce My Account registration

add_action('woocommerce_after_checkout_validation', function($data, $errors) {
    $email = isset($data['billing_email']) ? $data['billing_email'] : '';
    if (empty($email) || !defined('MAILODDS_API_KEY')) {
        return;
    }

    $response = wp_remote_post('https://api.mailodds.com/v1/validate', [
        'headers' => [
            'Authorization' => 'Bearer ' . MAILODDS_API_KEY,
            'Content-Type'  => 'application/json',
        ],
        'body'    => json_encode(['email' => $email]),
        'timeout' => 5,
    ]);

    if (is_wp_error($response)) {
        return; // Fail-open
    }

    $body = json_decode(wp_remote_retrieve_body($response), true);
    $result = isset($body['result']) ? $body['result'] : $body;

    if (isset($result['action']) && 'reject' === $result['action']) {
        $errors->add('validation',
            'This email address could not be verified. Please use a different email.');
    }
}, 10, 2);

WP-CLI Commands

Validate emails and manage users from the command line.

WP-CLI: MailOdds Commands

BASH
# WP-CLI commands (included in the plugin)

# Validate a single email
wp mailodds validate user@example.com

# Validate with JSON output
wp mailodds validate user@example.com --format=json

# Bulk validate all unvalidated WordPress users
wp mailodds bulk

# Bulk validate with batch size and limit
wp mailodds bulk --batch=100 --limit=500

# Show plugin status and stats
wp mailodds status

Frequently Asked Questions

Troubleshooting

Need more help?

Can't find what you're looking for? We're here to help you get WordPress working.

Block Fake Signups on WordPress

Get 1,000 free validations and start protecting your WordPress forms.