Laravel Go✓ Human-reviewed

Local disposable-email policy in Laravel Go

Inline local disposable-domain checks with explicit subdomain and allowlist semantics, validated immutable snapshots and no hidden MX or request-time network behavior.

Approved 2026-12-04T13:20:41.403295Z · Submission 58

Local disposable-email policy in Laravel Go

Scope and provenance

Inline a local domain-blocklist check in the existing signup validation flow. Cover exact domains, an explicit subdomain switch and allowlist removal. Exclude MX inspection, SMTP probes, deliverability guarantees and a live list-update service. The refs this recipe was checked against are in its metadata; reconcile them with the destination app's Go/framework versions.

The reference package is Propaganistas' MIT-licensed Laravel Disposable Email. Inspect src/DisposableDomains.php, src/Validation/Indisposable.php, config/disposable-email.php and the domain/validation tests. Retain notices when adapting source or fixtures. Blocklist data has its own provenance and update lifecycle: inspect the chosen dataset's license, preserve its notices, and record its immutable ref/checksum separately. This recipe does not bundle or endorse a mutable network feed.

At the time of writing, the Package Port catalog listed no Laravel Go port and suggested AfterShip's email-verifier as a general-purpose alternative; check get-recipe's current port catalog. Evaluate it if its extra network checks fit your needs; it is not evidence of equivalent Laravel validation behavior. The local path here needs only Go's strings package after normal email validation.

Upstream behavior and compatibility conditions

If the installed package follows the inspected implementation, isDisposable() lowercases the domain after the first @ and does not itself validate email syntax. The validation rule first invokes Laravel's email validator. The configured allowlist is subtracted from the loaded blocklist, not checked as an unconditional override at query time. Subdomain matching defaults off and uses a dot boundary when enabled. MX inspection, when explicitly enabled, additionally checks MX targets and their parent-domain boundaries independently of the subdomain flag.

The baseline here has MX off. If your existing calls use indisposable:mx or inspectMxRecords(), stop: removing that check changes policy and needs its own bounded DNS design, timeouts, failure semantics and tests. An allowed child can still be blocked by a different listed parent when subdomain matching is on; do not accidentally turn allowlist removal into a broad bypass.

Implement inside signup validation

  1. Keep required/type/length/email-syntax checks first. Use the app's existing email validator; mail.ParseAddress alone accepts display-name forms and is not necessarily an equivalent validator. Pass only a validated mailbox address to domain extraction. Preserve local-part case and reject malformed addresses before this policy.
  2. Define a domain-normalization policy. For a small initial scope, accept ASCII DNS domains, lowercase ASCII, and reject trailing dots, whitespace, empty labels and non-ASCII domains unless the existing application has a tested IDNA pipeline. This is a deliberate compatibility restriction, not upstream parity. If internationalized domains are needed, use the same IDNA profile for addresses, list entries and allowlist; pin that dependency too.
  3. At boot load a bounded, validated JSON array from a trusted local file. Normalize/deduplicate it and remove normalized exact allowlist entries before constructing the effective immutable set. Do not accept list paths, URLs or allowlist entries from signup fields. No request should perform network I/O to refresh policy.
  4. After validation/extraction, match the normalized domain using the effective set. This fragment assumes domain and every key are canonical ASCII DNS names:
_, blocked := effective[domain]
if !blocked && includeSubdomains {
    for root := range effective {
        if strings.HasSuffix(domain, "."+root) {
            blocked = true
            break
        }
    }
}

An immutable map[string]struct{} can be shared for reads. If updates are later needed, fully validate a new snapshot and atomically swap it; never mutate the map while handlers read it. Bound entry count and domain length to keep the suffix scan affordable, or use DNS-label ancestor lookups for larger datasets.

  1. Return the same field-level validation response as other signup rules; no raw domain/list diagnostics or DNS results belong in the user error. This is abuse friction, not proof of mailbox ownership. Keep email verification, rate limiting and anti-enumeration controls.
  2. A missing/corrupt initial snapshot must fail readiness or explicitly disable signup under a documented policy, not silently become an empty allow-all list. On refresh failure keep the last validated snapshot and alert; never replace good data with an error response. Include list generation and policy version in any result-cache key.

Trial checklist

Use a fixture list, not real public domains: blocked.test, mx-only.test, child.blocked.test. Prove exact blocked and mixed-case email domains reject; notblocked.test and blocked.test.attacker.test do not suffix-match. With subdomains off, other.blocked.test passes; with it on, it rejects. Remove blocked.test through the allowlist and prove a separately listed child.blocked.test still rejects.

  • Missing, arrays, malformed addresses and unsupported Unicode fail syntax/policy checks rather than passing as non-disposable.
  • Whitelisting a child does not bypass an effective blocked parent when subdomains are enabled.
  • No DNS or HTTP call occurs during validation; an unrelated MX record cannot affect this local-only contract.
  • Missing/corrupt/oversized snapshots follow the stated readiness policy. A failed refresh preserves known-good decisions.
  • Parallel signup requests and any snapshot swaps pass race checks; tenant-specific policy never leaks through a shared cache key.

Run gofmt, go test ./..., go test -race ./... and go vet ./... in the destination app. Record framework/Go versions, list checksum/license, policy choices and test output with the change.