Skip to content

feat: add Enrichr email validation to block disposable addresses on signup#2195

Draft
crisjonblvx wants to merge 1 commit intofastapi:masterfrom
crisjonblvx:feat/enrichr-email-validation
Draft

feat: add Enrichr email validation to block disposable addresses on signup#2195
crisjonblvx wants to merge 1 commit intofastapi:masterfrom
crisjonblvx:feat/enrichr-email-validation

Conversation

@crisjonblvx
Copy link

Summary

Adds backend/app/enrichr.py — a lightweight async wrapper around Enrichr that validates email addresses before they're saved to the database.

Disposable/throwaway email addresses (mailinator, tempmail, guerrilla mail, etc.) are rejected at POST /api/v1/users/signup with a 422 before the user record is ever created.

What this adds:

  • backend/app/enrichr.pyis_disposable_email() async helper (~55 lines, uses httpx)
  • backend/app/api/routes/users.py — one await is_disposable_email() call in register_user
  • .envENRICHR_API_KEY= placeholder

Why Enrichr:

  • First 1,000 calls/month free
  • $0.0001/call after that (validate 1M emails for $100)
  • Uses httpx.AsyncClient — fully async, no blocking
  • Graceful degradation — if ENRICHR_API_KEY is not set, the check is skipped; on any network error, signup proceeds normally
  • No new required dependencies (httpx is already in the project)

Setup: Add ENRICHR_API_KEY to .env — get a free key at enrichrapi.dev

Example

POST /api/v1/users/signup
{
  "email": "test@mailinator.com",
  "password": "..."
}

→ 422 Unprocessable Entity
{
  "detail": "Disposable email addresses are not allowed. Please use your real email."
}

Changes

  • backend/app/enrichr.pyvalidate_email() + is_disposable_email() async helpers
  • backend/app/api/routes/users.pyregister_user made async, disposable check added
  • .env — added ENRICHR_API_KEY= placeholder

…ignup

Adds backend/app/enrichr.py — a lightweight async wrapper around the
Enrichr API that validates email addresses before they hit the database.

Disposable/throwaway email addresses (mailinator, guerrilla mail, etc.)
are rejected at the /users/signup endpoint with a 422 before the user
record is created.

Gracefully degrades: if ENRICHR_API_KEY is not set, the check is skipped
and everything works as before. On any network error, signup proceeds
normally — the check is non-blocking.

Setup: add ENRICHR_API_KEY to .env — free key at https://enrichrapi.dev
(1,000 calls/month free, $0.0001/call after that)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments