Skip to main content
emailtoolspython
A series of methods to help you work with validation and extraction of e-mails


Install

>> pip install --user emailtoolspython


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

>> cd path/to/your/module
>> wget https://github.com/EvertonTomalok/emailtoolspython/archive/master.zip
>> unzip master.zip
>> cd emailtoolspython-master
>> python3 setup.py install --user

Usage

>> 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('evertontomalok123@gmail.com')
>> 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('24hours_laundry@gmail.com')
>> False
>> email.syntax_validation('24hours_laundry@gmail.com', 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('evertontomalok123@gmail.com')
>> 200

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

The domain wasn't founded.
>> email.email_smtp_validation('asdar1t1@214135135qsas1.com')
>> 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('gmail.com'))
>> {'status': 200, 'ip_address': 'str_containing_ip' } - Ok

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

Timeout, try later
>> email.domain_smtp_validation('a_timeout_ocurried.com'))
>> {'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 email@example.com sajdiosafhu. A example@email.com')
>> ['email@example.com', 'example@email.com']



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: "creditas.com.br" or "www.creditas.com.br" or another way "app.creditas.com.br".
An url from a contact page, can be passed too, like this: "http://laclaw.com.br/Contato-e-Localizacao.html".


>> email.extract_emails_from_web('creditas.com.br')
>> ['meajuda@creditas.com.br', 'ouvidoria@creditas.com.br', 'imprensa@creditas.com.br']


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

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

EXAMPLE
>> email.extract_emails_from_web('lendico.com.br', user_agent=True)
>> ['atendimento@lendico.com.br']



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('creditas.com.br', use_selenium=True, user_agent=True)
>> ['meajuda@creditas.com.br', 'ouvidoria@creditas.com.br', 'imprensa@creditas.com.br']

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

You can download chromedriver here (https://sites.google.com/a/chromium.org/chromedriver/downloads) and you can access the
official documentation - python bindings for selenium (https://selenium-python.readthedocs.io/installation.html).
For Windows users, go to the official documentation to have help to install chromedriver.

Author
{
'name': Everton Tomalok,
'email': evertontomalok123@gmail.com,
'medium': medium.com/@everton.tomalok,
'linkedin': linkedin.com/in/evertontomalok
}


Release files for emailtoolspython 0.4.5

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

Source distribution (sdist)

Source distribution for emailtoolspython 0.4.5
File Size Uploaded
emailtoolspython-0.4.5.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for emailtoolspython 0.4.5
File Interpreter ABI Platform
emailtoolspython-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / emailtoolspython-0.4.5.tar.gz

Download URL emailtoolspython-0.4.5.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
02e3fc14de03a0cbf2a764c718a4fe079e42774fc6fd9a5e01f14f96c63c69f3
BLAKE2b-256 checksum
How to use checksums
b8cfbf400b2e16e91b621bb0b25b152d3165307bf3f37a329277615865139084
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

Release files / emailtoolspython-0.4.5-py3-none-any.whl

Download URL emailtoolspython-0.4.5-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb3b8fa6efc0b3c65df8fbd03cc8956a8f7d0c11fd5cafbb34829695b6acde7a
BLAKE2b-256 checksum
How to use checksums
9639f5d65ea5c08a7026af4584854b31fd50074523372ff4fc80d1ecc6e96c80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.4.5 This release

2 release files

0.4.4

2 release files

0.4

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

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