h-farm/laravel-email-domain-rule
A Laravel validation rule for checking the domain of an email address. Allow or block specific domains, filter disposable or corporate emails, and get clear validation messages—drop it into form requests or validators with minimal setup.
str_ends_with checks scattered across controllers, form requests, and API handlers.Adopt it when:
gmail.com, mailinator.com; allow *.acme.com), not heuristic classification.Look elsewhere when:
To executives: This is a small, zero-cost open-source utility that lets us enforce "who can sign up" rules — for example, work-email-only registration or blocking throwaway inboxes — consistently across every surface of the product. It is not a platform bet: the logic is simple, the licence is permissive, and we could replace it in an afternoon. The new 3.2.0 release adds PHP 8.3 and Laravel 11 support, which means it no longer blocks our framework upgrade and carries no breaking changes. The one thing to be clear on is that domain policy is a business decision we still own; the package enforces rules, it does not tell us which domains to block or supply a live fraud database. Approve as a routine engineering dependency, and route the actual signup-policy question — do we accept free-email signups? — through product.
To engineering: Use it as the single validation rule for domain policy instead of hand-rolled string checks so the rule is testable and consistent across FormRequests, API endpoints, and admin/invite flows. Pin to ^3.2 given the Laravel 11 and PHP 8.3 compatibility work; no breaking changes are introduced, so upgrading from 3.x is low-risk. Keep the domain lists in config rather than in code so product can tune them without a release, and add a test asserting the list is non-empty and loaded — an empty allowlist that silently permits everything is the realistic failure mode here. Also confirm whether the package ships a disposable-domain list or expects one from us; if the latter, decide early who owns refreshing it, because an unmaintained blocklist decays into a false sense of security.
How can I help you explore Laravel packages today?