Skip to main content

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 Domain Folding
Apple x x†
Fastmail x x
Google x 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)
  • Domain Folding: Rewrites provider alias domains to a single canonical domain

* 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).

† Some providers deliver one mailbox under several domain names. These alias domains are folded to a single canonical form so the same mailbox always normalizes to the same address: Google's googlemail.comgmail.com, and Apple's me.com and mac.comicloud.com. Domains that share a provider but are separate mailboxes (e.g. Microsoft's outlook.com/hotmail.com, or Yahoo's yahoo.com/aol.com) are intentionally left unchanged.

Documentation

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

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.2.0.tar.gz (42.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.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for email_normalize-3.2.0.tar.gz
Algorithm Hash digest
SHA256 f83c0e96a9a6c0aa84e746a9f4c4772b85d1bd7a9833a52065b0b73510945f06
MD5 4120a5e83a6ebe41c9da8dccc68d5e0a
BLAKE2b-256 188740b9778e0004358c237410ad95b76627c9eae8e7171c2b163faa25df3c03

See more details on using hashes here.

Provenance

The following attestation bundles were made for email_normalize-3.2.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for email_normalize-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3497f57c2f010f6e4aa9c7473d225fda37da0ed37adfbbd2d2a7146dee041920
MD5 7b81310ffc698d2f22521b4173365a93
BLAKE2b-256 f9663cd3fa4d43eca27b482bc8be0481b3d2b6f313ff77134a1445cc81f9d9f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for email_normalize-3.2.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