Skip to main content

A series of methods to help you work with validation and extraction of e-mails

Project description

A series of methods to help you work with validation and extraction of e-mails


>> pip install --user emailtoolspython

Or you can download the zip of the module, to your root project

>> cd path/to/your/module
>> wget
>> unzip
>> cd emailtoolspython-master
>> python3 install --user


>> from emailtoolspython import EmailTools

>> email = EmailTools()

Syntax Email Validation
To verify if the syntax of an email is valid, use the method below:

>> email.syntax_validation('')
>> True
>> email.syntax_validation('example@invalid_domain')
>> False

Passing the Parameter "can_start_with_number=True", you can verify e-mail that starts a number:

>> email.syntax_validation('')
>> False
>> email.syntax_validation('', can_start_with_number=True)
>> True

Email SMTP Validation

Pass an email to verify if domain is registered as a server, and if the email passed exists or not.

The example bellow is a valid email
>> email.email_smtp_validation('')
>> 200

It isn't valid or the email couldn't be validated!
>> email.email_smtp_validation('')
>> 400

The domain wasn't founded.
>> email.email_smtp_validation('')
>> 402

The syntax is invalid
>> email.email_smtp_validation('not_a_valid_email@not-domain')
>> 403

All returns:
200 - The email is valid
400 - The email is invalid
401 - Try later
402 - The domain wasn't founded
403 - The syntax is invalid

Validating a domain
A valid domain
>> email.domain_smtp_validation(''))
>> {'status': 200, 'ip_address': 'str_containing_ip' } - Ok

An invalid domain
>> email.domain_smtp_validation(''))
>> {'status': 400, 'ip_address': None } - Not Found

Timeout, try later
>> email.domain_smtp_validation(''))
>> {'status': 401, 'ip_address': None } - Try Later

Extracting Emails from a text
To extract all emails from a text, use extract_emails_from_text():

>> email.extract_emails_from_text('lorsi sldaljq indajfa sajdiosafhu. A')
>> ['', '']

Extracting Emails from a web page
You can pass a site domain to extract_emails_from_web(), and all emails crawled in that page, will be returned in a list.
Note, a domain must be passed like this: "" or "" or another way "".
An url from a contact page, can be passed too, like this: "".

>> email.extract_emails_from_web('')
>> ['', '', '']

Use parameter "user_agent=True" to choose a random user agent to be used in the request

>> email.extract_emails_from_web('', user_agent=True)

>> email.extract_emails_from_web('', user_agent=True)
>> ['']

You can use selenium (a webdriver that simulate you are using Google Chrome to access some page) to run and crawl web pages
that need to execute javascript.
Is very simple use this feature, you only need to have chromedriver in your path /usr/bin or /usr/local/bin, and pass the parameter
"use_selenium" as True. It's important to mention, that the speed of the crawl will decrease.

Extract emails using Selenium in headless

>> email.extract_emails_from_web('', use_selenium=True, user_agent=True)
>> ['', '', '']

Using selenium, user_agent is not necessary. You can pass user_agent=False, if you want.

You can download chromedriver here ( and you can access the
official documentation - python bindings for selenium (
For Windows users, go to the official documentation to have help to install chromedriver.

'name': Everton Tomalok,

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
emailtoolspython-0.4.5-py3-none-any.whl (10.4 kB) Copy SHA256 hash SHA256 Wheel py3
emailtoolspython-0.4.5.tar.gz (11.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page