JoshData / JoshData/python-email-validator

Proposal: Add an async email validation function using dnspython’s async resolver

Open
#164 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
140
PR merge metrics
No merged PRs in 30d

Description

I maintain a high-volume lead-gen API that validates thousands of emails per request. To keep latency low, we can’t rely on the library’s check_deliverability=True option because it triggers blocking DNS lookups. Instead, we run the library with deliverability checks disabled and perform our own async DNS queries via dns.asyncresolver.

It would be a real improvement if the library exposed a first-class async deliverability path. Below is a minimal prototype showing what that could look like:

from email_validator import validate_email, EmailNotValidError, ValidatedEmail
import dns.asyncresolver

dns_resolver = dns.asyncresolver.Resolver()

async def _resolve_mail_hosts(domain: str):
    try: return await dns_resolver.resolve(domain, "MX")
    except Exception:
        for record_type in ("A", "AAAA"):
            try: return await dns_resolver.resolve(domain, record_type)
            except Exception: continue
        return None

async def aio_validate_email(email: str) -> ValidatedEmail:
    email_info = validate_email(email, check_deliverability=False)
    if await _resolve_mail_hosts(email_info.domain) is None: raise EmailNotValidError
    return email_info

My plan is to open a PR that adds an async validator fully compatible with your existing Pydantic models, plus tests and documentation. Before I invest the time, are you open to adding async support to the project?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing validate_email, ValidatedEmail, EmailNotValidError, the existing Pydantic models, and the proposed dns.asyncresolver flow. The work is complete when the project has a first-class async deliverability validator compatible with those models, along with the planned tests and documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.