EmailVerify LogoEmailVerify

WordPress

Email checker for WordPress. Verify emails in contact forms, WooCommerce, and user registration.

WordPress 사이트에 실시간 이메일 검증을 추가하세요. 문의 폼, 등록, WooCommerce 결제에서 이메일을 검증합니다.

통합 방법

방법적합 대상복잡도
플러그인빠른 설정낮음
Contact Form 7CF7 사용자낮음
WPFormsWPForms 사용자낮음
커스텀 PHP완전한 제어중간

방법 1: EmailVerify 플러그인

가장 쉬운 통합을 위해 공식 WordPress 플러그인을 설치하세요.

설치

  1. 플러그인새로 추가로 이동
  2. "EmailVerify Email Verification" 검색
  3. 지금 설치를 클릭한 다음 활성화
  4. 설정EmailVerify로 이동
  5. API 키 입력

구성

// wp-config.php (optional)
define('EMAILVERIFY_API_KEY', 'bv_live_xxx');

기능

  • 모든 폼에서 실시간 검증
  • 일회용 이메일 차단
  • 역할 기반 이메일 차단
  • 사용자 정의 오류 메시지
  • WooCommerce 통합
  • AJAX 검증

방법 2: Contact Form 7

Contact Form 7 폼에 검증을 추가합니다.

훅 사용

// functions.php
add_filter('wpcf7_validate_email*', 'emailverify_cf7_validation', 20, 2);

function emailverify_cf7_validation($result, $tag) {
    $email = isset($_POST[$tag->name]) ? sanitize_email($_POST[$tag->name]) : '';

    if (empty($email)) {
        return $result;
    }

    $verification = emailverify_check_email($email);

    if ($verification['status'] === 'invalid') {
        $result->invalidate($tag, 'Please enter a valid email address.');
    }

    if ($verification['result']['disposable']) {
        $result->invalidate($tag, 'Disposable emails are not allowed.');
    }

    return $result;
}

function emailverify_check_email($email) {
    $api_key = defined('EMAILVERIFY_API_KEY')
        ? EMAILVERIFY_API_KEY
        : get_option('emailverify_api_key');

    $response = wp_remote_post('https://api.emailverify.ai/v1/verify', [
        'headers' => [
            'Authorization' => 'Bearer ' . $api_key,
            'Content-Type' => 'application/json',
        ],
        'body' => json_encode(['email' => $email]),
        'timeout' => 10,
    ]);

    if (is_wp_error($response)) {
        return ['status' => 'unknown'];
    }

    return json_decode(wp_remote_retrieve_body($response), true);
}

폼 태그 구성

[email* your-email class:emailverify-email]

방법 3: WPForms

커스텀 검증을 사용하여 WPForms와 통합합니다.

PHP 검증

// functions.php
add_filter('wpforms_process_before_form_data', 'emailverify_wpforms_validation', 10, 2);

function emailverify_wpforms_validation($form_data, $entry) {
    foreach ($entry['fields'] as $field_id => $value) {
        $field = $form_data['fields'][$field_id] ?? null;

        if ($field && $field['type'] === 'email' && !empty($value)) {
            $verification = emailverify_check_email($value);

            if ($verification['status'] === 'invalid') {
                wpforms()->process->errors[$form_data['id']][$field_id] =
                    'Please enter a valid email address.';
            }

            if ($verification['result']['disposable'] ?? false) {
                wpforms()->process->errors[$form_data['id']][$field_id] =
                    'Disposable emails are not allowed.';
            }
        }
    }

    return $form_data;
}

방법 4: 커스텀 PHP 통합

완전한 제어를 위해 API와 직접 통합합니다.

헬퍼 클래스

<?php
// includes/class-emailverify.php

class EmailVerify {
    private $api_key;
    private $api_url = 'https://api.emailverify.ai/v1';

    public function __construct($api_key = null) {
        $this->api_key = $api_key ?: get_option('emailverify_api_key');
    }

    public function verify($email) {
        $response = wp_remote_post($this->api_url . '/verify', [
            'headers' => [
                'Authorization' => 'Bearer ' . $this->api_key,
                'Content-Type' => 'application/json',
            ],
            'body' => json_encode(['email' => $email]),
            'timeout' => 10,
        ]);

        if (is_wp_error($response)) {
            return [
                'success' => false,
                'error' => $response->get_error_message(),
            ];
        }

        $body = json_decode(wp_remote_retrieve_body($response), true);
        return [
            'success' => true,
            'data' => $body,
        ];
    }

    public function is_valid($email) {
        $result = $this->verify($email);
        return $result['success'] && $result['data']['status'] === 'valid';
    }

    public function is_disposable($email) {
        $result = $this->verify($email);
        return $result['success'] && ($result['data']['result']['disposable'] ?? false);
    }
}

사용법

$bv = new EmailVerify();

// Basic verification
$result = $bv->verify('user@example.com');

if ($result['data']['status'] === 'valid') {
    // Email is valid
}

// Quick checks
if ($bv->is_valid('user@example.com')) {
    // Process valid email
}

if ($bv->is_disposable('user@example.com')) {
    // Block disposable email
}

WordPress 등록

사용자 등록 시 이메일을 검증합니다.

// functions.php
add_filter('registration_errors', 'emailverify_registration_check', 10, 3);

function emailverify_registration_check($errors, $sanitized_user_login, $user_email) {
    $bv = new EmailVerify();
    $result = $bv->verify($user_email);

    if (!$result['success']) {
        return $errors; // Allow registration if API fails
    }

    $data = $result['data'];

    if ($data['status'] === 'invalid') {
        $errors->add('invalid_email',
            '<strong>Error</strong>: Please enter a valid email address.');
    }

    if ($data['result']['disposable'] ?? false) {
        $errors->add('disposable_email',
            '<strong>Error</strong>: Temporary email addresses are not allowed.');
    }

    return $errors;
}

AJAX 검증

JavaScript로 실시간 검증을 추가합니다.

PHP 엔드포인트

// functions.php
add_action('wp_ajax_verify_email', 'emailverify_ajax_verify');
add_action('wp_ajax_nopriv_verify_email', 'emailverify_ajax_verify');

function emailverify_ajax_verify() {
    check_ajax_referer('emailverify_nonce', 'nonce');

    $email = sanitize_email($_POST['email'] ?? '');

    if (empty($email)) {
        wp_send_json_error(['message' => 'Email is required']);
    }

    $bv = new EmailVerify();
    $result = $bv->verify($email);

    if ($result['success']) {
        wp_send_json_success($result['data']);
    } else {
        wp_send_json_error(['message' => 'Verification failed']);
    }
}

// Enqueue scripts
add_action('wp_enqueue_scripts', 'emailverify_enqueue_scripts');

function emailverify_enqueue_scripts() {
    wp_enqueue_script('emailverify',
        get_template_directory_uri() . '/js/emailverify.js',
        ['jquery'],
        '1.0.0',
        true
    );

    wp_localize_script('emailverify', 'emailverify_ajax', [
        'url' => admin_url('admin-ajax.php'),
        'nonce' => wp_create_nonce('emailverify_nonce'),
    ]);
}

JavaScript

// js/emailverify.js
jQuery(function($) {
    $('input[type="email"]').on('blur', function() {
        var $input = $(this);
        var email = $input.val();

        if (!email) return;

        $input.addClass('verifying');

        $.post(emailverify_ajax.url, {
            action: 'verify_email',
            nonce: emailverify_ajax.nonce,
            email: email
        })
        .done(function(response) {
            $input.removeClass('verifying');

            if (response.success) {
                var data = response.data;

                if (data.status === 'invalid') {
                    showError($input, 'Please enter a valid email');
                } else if (data.result && data.result.disposable) {
                    showError($input, 'Disposable emails not allowed');
                } else {
                    showSuccess($input);
                }
            }
        })
        .fail(function() {
            $input.removeClass('verifying');
        });
    });

    function showError($input, message) {
        $input.addClass('error').removeClass('valid');
        $input.next('.bv-message').remove();
        $input.after('<span class="bv-message error">' + message + '</span>');
    }

    function showSuccess($input) {
        $input.addClass('valid').removeClass('error');
        $input.next('.bv-message').remove();
        $input.after('<span class="bv-message valid">✓</span>');
    }
});

CSS

/* style.css */
input[type="email"].verifying {
    background-image: url('spinner.gif');
    background-position: right 10px center;
    background-repeat: no-repeat;
}

input[type="email"].error {
    border-color: #dc3545;
}

input[type="email"].valid {
    border-color: #28a745;
}

.bv-message {
    display: block;
    font-size: 12px;
    margin-top: 4px;
}

.bv-message.error {
    color: #dc3545;
}

.bv-message.valid {
    color: #28a745;
}

캐싱

API 호출을 줄이기 위해 검증 결과를 캐싱합니다.

function emailverify_check_email_cached($email) {
    $cache_key = 'bv_email_' . md5($email);
    $cached = get_transient($cache_key);

    if ($cached !== false) {
        return $cached;
    }

    $result = emailverify_check_email($email);

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

    return $result;
}

모범 사례

1. 그레이스풀 디그레이데이션

API 실패 시 항상 폼 제출 허용:

$result = $bv->verify($email);

if (!$result['success']) {
    // Log the error but don't block the user
    error_log('EmailVerify API error: ' . $result['error']);
    return; // Allow submission
}

2. 속도 제한

속도 제한으로 남용 방지:

function emailverify_rate_limit($email) {
    $ip = $_SERVER['REMOTE_ADDR'];
    $key = 'bv_rate_' . md5($ip);
    $count = get_transient($key) ?: 0;

    if ($count >= 10) { // 10 verifications per minute
        return false;
    }

    set_transient($key, $count + 1, MINUTE_IN_SECONDS);
    return true;
}

3. 보안

항상 입력을 살균하고 검증:

$email = sanitize_email($_POST['email']);

if (!is_email($email)) {
    // Invalid format, no need to call API
    return;
}

관련 리소스

On this page