Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Email Check Laravel Package

voku/email-check

Validates email addresses in PHP with multiple checks (syntax, DNS/MX, disposable domains and more) to reduce bounces and fake signups. Lightweight library with simple API, suitable for signup forms, user imports, and email hygiene workflows.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:

    • Lightweight (~1.07 score) and focused on a single, critical validation use case (email verification).
    • Complements Laravel’s built-in Illuminate\Validation by adding DNS, disposable/trash domain, and typo detection—features not natively supported.
    • Stateless and dependency-light, making it ideal for microservices or monolithic apps where validation is decoupled from business logic.
    • MIT license ensures no legal barriers to adoption.
  • Fit Gaps:

    • No built-in rate-limiting for DNS checks (could flood DNS servers if abused).
    • No async support—synchronous DNS/trash checks may block request threads in high-traffic apps.
    • No caching layer for DNS/trash results (repeated checks for the same domain are inefficient).
    • No integration with Laravel’s queue system (e.g., shouldQueue() for async validation).

Integration Feasibility

  • Laravel Ecosystem Synergy:

    • Works seamlessly with Laravel’s Form Request validation (validate() method) via custom rules.
    • Can be wrapped in a Laravel Service Provider for centralized configuration (e.g., DNS timeout, trash domains list).
    • Supports Laravel’s container for dependency injection (e.g., EmailValidator facade).
  • Example Integration:

    use Voku\Helper\Email;
    use Illuminate\Validation\Rule;
    
    Rule::macro('validEmail', function ($field, $attribute, $fail) {
        $email = request()->input($field);
        $validator = new Email();
        if (!$validator->isEmail($email)) {
            $fail("The {$attribute} must be a valid email address.");
        }
    });
    

    Usage:

    $request->validate([
        'email' => ['required', new \App\Rules\ValidEmail],
    ]);
    

Technical Risk

Risk Area Severity Mitigation Strategy
DNS Performance High Implement caching (Redis) for DNS/trash checks.
False Positives Medium Extend trash domain list via config.
Thread Blocking Medium Offload to Laravel Queues for async validation.
Dependency Bloat Low Minimal; only voku/email-check + caching layer.
Maintenance Overhead Low MIT license allows forks if upstream stalls.

Key Questions

  1. DNS Reliability:

    • How will we handle DNS failures (e.g., network timeouts, NXDOMAIN) without blocking requests?
    • Solution: Fallback to syntax-only validation or async queue.
  2. Trash Domain List:

    • How frequently will we update the disposable email list (e.g., from mailboxlayer)?
    • Solution: Cache locally with TTL, expose config for custom lists.
  3. Async Validation:

    • Should email validation be synchronous (for real-time feedback) or asynchronous (for background jobs)?
    • Solution: Hybrid approach—sync for signup, async for profile updates.
  4. Testing Coverage:

    • How will we test edge cases (e.g., international emails, subdomains, typos)?
    • Solution: Unit tests + integration tests with mocked DNS responses.
  5. Monitoring:

    • How will we track validation failures (e.g., DNS timeouts, invalid formats)?
    • Solution: Log failures to Laravel’s log channel or a monitoring tool (e.g., Sentry).

Integration Approach

Stack Fit

  • Laravel Core:

    • Validation: Replace or extend Illuminate\Validation\Rules\Email with voku/email-check.
    • Service Container: Bind Voku\Helper\Email as a singleton for reuse.
    • Events: Trigger email.validated or email.invalid events for downstream processing.
  • Additional Stack Components:

    • Caching: Redis/Memcached for DNS/trash results (TTL: 1 hour).
    • Queues: Laravel Queues for async validation jobs.
    • Monitoring: Laravel Horizon or StatsD for tracking validation metrics.

Migration Path

  1. Phase 1: Syntax-Only Validation

    • Replace Laravel’s default email rule with voku/email-check for syntax validation.
    • Risk: Minimal; backward-compatible.
  2. Phase 2: DNS Validation

    • Enable DNS checks via config ('dns_check' => true).
    • Add Redis caching for DNS responses.
    • Risk: Moderate; requires caching layer setup.
  3. Phase 3: Async Validation

    • Move DNS/trash checks to a queued job (HandleEmailValidation).
    • Update UI to show a "pending" state for async-validated emails.
    • Risk: High; requires queue worker setup and UX changes.
  4. Phase 4: Trash Domain List

    • Integrate a third-party API (e.g., MailboxLayer) for dynamic trash domain updates.
    • Risk: Low; optional enhancement.

Compatibility

  • Laravel Versions:
    • Compatible with Laravel 8+ (PHP 7.4+). Tested with Laravel 9/10 for dependency conflicts.
  • PHP Extensions:
    • Requires dns extension (enabled by default in most Laravel deployments).
  • Database:
    • No schema changes; pure validation logic.

Sequencing

Step Priority Dependencies Effort
Install package High None Low
Basic syntax rule High Laravel Validation Low
Redis caching Medium Redis setup Medium
Async queue job Low Queue workers, UX updates High
Trash domain API Optional Third-party API key Medium

Operational Impact

Maintenance

  • Pros:
    • Minimal maintenance: MIT license, no vendor lock-in.
    • Configurable: Trash domains, DNS timeout, and validation rules can be adjusted via .env.
  • Cons:
    • Trash domain list updates: Requires manual or automated refreshes.
    • DNS changes: If a domain’s MX records change, validation may fail temporarily.

Support

  • Debugging:
    • Log validation failures with context (e.g., email, dns_error, trash_domain).
    • Example log:
      {
        "email": "user@example-trash.com",
        "valid": false,
        "reason": "disposable_domain",
        "timestamp": "2023-10-01T12:00:00Z"
      }
      
  • User Communication:
    • Provide clear error messages (e.g., "This email is from a temporary domain. Please use a permanent address.").
    • For async validation, show a "Verification pending" state.

Scaling

  • Performance:
    • Synchronous: DNS checks add ~100–300ms latency per request (varies by DNS provider).
    • Asynchronous: Offloads work to queues; no impact on request response time.
  • Load Testing:
    • Simulate 1000 RPS to measure DNS queue depth and caching efficiency.
    • Tool: Laravel Dusk + Artisan commands for load testing.

Failure Modes

Failure Scenario Impact Mitigation
DNS Server Unavailable Validation fails silently Fallback to syntax-only validation.
Redis Cache Failure Repeated DNS checks Local file-based fallback cache.
Queue Worker Crash Async validations stall Retry logic + dead-letter queue.
Trash Domain List Stale False positives/negatives Automated API refresh (e.g., cron).

Ramp-Up

  • Developer Onboarding:

    • Documentation: Add a EMAIL_VALIDATION.md to the project with:
      • Installation steps.
      • Config options (config/email-validation.php).
      • Example usage in Form Requests.
    • Training: 30-minute session on:
      • When to use sync vs. async validation.
      • Debugging DNS/trash issues.
  • Release Strategy:

    • Canary Release: Enable for 10% of users first (via feature flag).
    • Feature Flags: Toggle DNS/trash checks via config('email-validation.enabled').
    • Rollback Plan: Disable via config if failure rate exceeds 5%.
  • Metrics to Track:

    • Validation Success Rate: % of emails passing all checks.
    • **DNS Check Latency
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle