Skip to main content

email2country (Python Package)

This is an easy-to-use Python package to look up the country given an email address. The GitHub project is at email2country.

Installation

Requirement: Python 3

pip install --upgrade git+git://github.com/zhijing-jin/email2country.git

How to Run

(All country names are conssitent with ISO 3166-1)

Function 1: Find the country where the email server is located

>>> from email2country import email2country
>>> email2country('zhijing@mit.edu')
'United States'

Or you can just use the domain

>>> email2country('connect.hku.hk')
'Hong Kong'

Function 2: Find the country where the institution of this email address is located

>>> from email2country import Email, email2institution_country

>>> email2institution_country('zhijing@mit.edu')
'United States'

>>> email2institution_country('zhijing@gmail.com')
[Info] Email domain "gmail.com" is generic. There is no specific country.

>>> email2institution_country('zhijing@gmail.com111')
[Info] Country not found for "gmail.com111"

Function 3: Look up in batches

>>> from email2country import batch_email2institution_country
>>> batch_email2institution_country(['nyu.edu','gmail.com', 'hku.hk'])
['United States', None, 'Hong Kong']

# or you can enable the "enable warning" option:
>>> batch_email2institution_country(['nyu.edu','gmail.com', 'hku.hk'], enable_warning=True)
[Info] Email domain "gmail.com" is generic. There is no specific country.
['United States', None, 'Hong Kong']

# Similarly, you can try email2country lookup
>>> from email2country import batch_email2country
>>> batch_email2country(['nyu.edu','gmail.com', 'hku.hk'])

Function 4: Customize your own function

You can use the EmailCountryChecker object directly:

>>> from email2country import EmailCountryChecker
>>> checker = EmailCountryChecker()
>>> checker.get_institution_country('hku.hk', enable_warning=True)
'Hong Kong'
>>> # ... Perform your own actions

Or you can use the Email object

>>> from email2country import Email 
>>> addr = 'zhijing@mit.edu'
>>> email = Email(addr)
>>> email.country
'United States'
>>> email.institution_country
'United States'

Contact

If you have more questions, feel free to contact the author Zhijing Jin (Miss).

Metadata

Release files for email2country 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for email2country 0.1.0
File Size Uploaded Provenance Actions
email2country-0.1.0.tar.gz 193.7 kB Without provenance Details for email2country-0.1.0.tar.gz

Release files / email2country-0.1.0.tar.gz

Download URL email2country-0.1.0.tar.gz
Size 193.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a38a3f237f555e30ef49f70821a3fb0d4ab15f85750908271f910c7ea8431531
BLAKE2b-256 checksum
How to use checksums
30d67a8d5412b54e738ae38a9551c58a8eea92c22831167cc0631e45e973dfe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.4.2 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

Security for email2country 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page