Skip to main content

Return a normalized email-address stripping ISP specific behaviors

Project description

email-normalize

A Python 3.11+ library for normalizing email addresses by stripping mailbox-provider-specific behaviors such as plus addressing (foo+bar@gmail.com) and period ignoring (f.o.o@gmail.com).

Version Status Coverage License

Installation

pip install email-normalize

Usage

Synchronous

import email_normalize

result = email_normalize.normalize('f.o.o+bar@gmail.com')
print(result.normalized_address)  # foo@gmail.com
print(result.mailbox_provider)    # Google
print(result.mx_records)          # [(5, 'gmail-smtp-in.l.google.com'), ...]

Async

For use within an asyncio application, use the Normalizer class directly:

import asyncio

import email_normalize


async def main():
    normalizer = email_normalize.Normalizer()
    result = await normalizer.normalize('f.o.o+bar@gmail.com')
    print(result.normalized_address)

asyncio.run(main())

The Normalizer maintains a LFRU cache of MX lookups, making it efficient for batch processing.

Without DNS Lookups

Use skip_dns=True to normalize against well-known domains without performing MX record lookups:

result = email_normalize.normalize('user+tag@gmail.com', skip_dns=True)

This mode uses a static domain map and will not detect providers for custom domains.

Normalization Rules

Provider Plus Addressing Strip Periods Local Part as Hostname
Apple x
Fastmail x x
Google x x*
Microsoft x
ProtonMail x
Rackspace x
Yahoo
Yandex x
Zoho x
  • Plus Addressing: Strips everything after + in the local part
  • Strip Periods: Removes . from the local part
  • Local Part as Hostname: Extracts the subdomain as the local part (Fastmail custom domains)

* Google strips periods only for consumer Gmail addresses (gmail.com and googlemail.com). Google Workspace custom domains route through the same MX servers but treat periods as significant, so periods are preserved for them (plus addressing is still stripped).

Documentation

Full documentation is available at gmr.github.io/email-normalize.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

email_normalize-3.1.0.tar.gz (68.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

email_normalize-3.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file email_normalize-3.1.0.tar.gz.

File metadata

  • Download URL: email_normalize-3.1.0.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for email_normalize-3.1.0.tar.gz
Algorithm Hash digest
SHA256 d226bed0eddb1aba2b02bd007292e95c6ca554751402c7a8821fcbb0005e4e40
MD5 c65483bfc33d7b31ee7e2e69f22117f0
BLAKE2b-256 0220cf96d09bfd1b5c247e4179da7412e2bcc04a1f288c6efbd5f913262de4f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for email_normalize-3.1.0.tar.gz:

Publisher: deploy.yaml on gmr/email-normalize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file email_normalize-3.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for email_normalize-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a1bf330e021ab1b119603f057b0791ca473d56a6cdf2bab0968414b4e228d12
MD5 50a76ecca8da0bd4a4d97ba592f2c719
BLAKE2b-256 8c4540140e74dce9c513e7192c611bf25e492251ceed3b411e4a1eb244e330b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for email_normalize-3.1.0-py3-none-any.whl:

Publisher: deploy.yaml on gmr/email-normalize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page