Skip to main content

Email validator with regex, blacklisted domains and SMTP checking.

Project description

https://travis-ci.org/karolyi/py3-validate-email.svg?branch=master https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png

py3-validate-email

py3-validate-email is a package for Python that check if an email is valid, not blacklisted, properly formatted and really exists.

This module is for Python 3.6 and above!

INSTALLATION

You can install the package with pip:

python -m pip install py3-validate-email

USAGE

Basic usage:

from validate_email import validate_email
is_valid = validate_email(email_address='example@example.com', check_regex=True, check_mx=True, from_address='my@from.addr.ess', helo_host='my.host.name', smtp_timeout=10, dns_timeout=10, use_blacklist=True)

check_regex will check will the email address has a valid structure and defaults to True

check_mx: check the mx-records and check whether the email actually exists

from_address: the email address the probe will be sent from,

helo_host: the host to use in SMTP HELO when checking for an email,

smtp_timeout: seconds until SMTP timeout

dns_timeout: seconds until DNS timeout

use_blacklist: use the blacklist of domains downloaded from https://github.com/martenson/disposable-email-domains

The function validate_email_or_fail() works exactly like validate_email, except that it raises an exception in the case of validation failure instead of returning False.

Auto-updater

The package contains an auto-updater for downloading and updating the built-in blacklist.txt. It will run on each module load (and installation), but will try to update the content only if the file is older than 5 days, and if the content is not the same that’s already downloaded.

The update can be triggered manually:

from validate_email.updater import update_builtin_blacklist

update_builtin_blacklist(force: bool = False, background: bool = True,
    callback: Callable = None) -> Optional[Thread]

force: forces the update even if the downloaded/installed file is fresh enough.

background: starts the update in a Thread so it won’t make your code hang while it’s updating. If you set this to true, the function will return the Thread used for starting the update so you can join() it if necessary.

callback: An optional Callable (function/method) to be called when the update is done.

TODOs and BUGS

See: https://github.com/karolyi/py3-validate-email/issues

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

py3-validate-email-0.2.8.tar.gz (10.5 kB view details)

Uploaded Source

File details

Details for the file py3-validate-email-0.2.8.tar.gz.

File metadata

  • Download URL: py3-validate-email-0.2.8.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for py3-validate-email-0.2.8.tar.gz
Algorithm Hash digest
SHA256 fbc7d76ed87637fca2d496a62f2dbac9078990a19e2a5421dfffc9104c08390f
MD5 11d1f8e5026fb7a90041d3aae4fa2ea9
BLAKE2b-256 7b5b40033a3239132a5394fdbf9347f872bf1382189e066f7ff286160ec4bc93

See more details on using hashes here.

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