Skip to main content

A package to look up the country of email addresses and domains

Project description

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.


Requirement: Python 3

pip install --upgrade git+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('')
'United States'

Or you can just use the domain

>>> email2country('')
'Hong Kong'

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

>>> from email2country import Email, email2institution_country

>>> email2institution_country('')
'United States'

>>> email2institution_country('')
[Info] Email domain "" 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(['','', ''])
['United States', None, 'Hong Kong']

# or you can enable the "enable warning" option:
>>> batch_email2institution_country(['','', ''], enable_warning=True)
[Info] Email domain "" 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(['','', ''])

Function 4: Customize your own function

You can use the EmailCountryChecker object directly:

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

Or you can use the Email object

>>> from email2country import Email 
>>> addr = ''
>>> email = Email(addr)
'United States'
>>> email.institution_country
'United States'


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

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

email2country-0.1.0.tar.gz (193.7 kB view hashes)

Uploaded Source

Supported by

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