Check if an email is valid with using SMTP, regexes and blacklists https://gitea.ksol.io/karolyi/py3-validate-email/
Go to file
Reinhard Müller 182f793def Clean up initial blacklist download on install
Two essential changes were made to the process of initially downloading
the blacklist at install time, allowing the removal of a number of hacks
and workarounds:

1. Download the files *after* populating the build directory instead of
*before*. Thus, the files don't have to be included in MANIFEST.in, and
following from that, `setup.py sdist` needn't be tricked into not
including them in the source distribution.

2. Only import the updater module instead of the full validate_email
package, so `setup.py install` and friends don't depend on all the
requirements of the library.
2020-04-14 12:16:36 +02:00
.github Update FUNDING.yml 2019-12-05 22:36:55 +01:00
tests Clean up initial blacklist download on install 2020-04-14 12:16:36 +02:00
validate_email Clean up initial blacklist download on install 2020-04-14 12:16:36 +02:00
.gitignore Add auto-updater 2019-11-24 18:13:02 +01:00
.isort.cfg Renaming package, adding isort 2019-03-01 23:29:01 +01:00
.travis.yml Clean up initial blacklist download on install 2020-04-14 12:16:36 +02:00
AUTHORS Beautifying code, updating AUTHORS+CHANGELOG 2020-04-10 13:26:06 +02:00
CHANGELOG.txt Adding release 2020-04-13 10:58:38 +02:00
LICENSE Updated license to be LGPL. Fixed #22 2014-07-03 11:34:25 +02:00
MANIFEST.in Clean up initial blacklist download on install 2020-04-14 12:16:36 +02:00
README.rst Replace MethodType to Callable 2020-04-11 17:54:34 +02:00
setup.cfg Renaming package, adding isort 2019-03-01 23:29:01 +01:00
setup.py Clean up initial blacklist download on install 2020-04-14 12:16:36 +02:00

README.rst

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

============================
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)

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

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

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

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

:code:`smtp_timeout`: seconds until SMTP timeout

:code:`dns_timeout`: seconds until DNS timeout

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

The function :code:`validate_email_or_fail()` works exactly like :code:`validate_email`, except that it raises an exception in the case of validation failure instead of returning :code:`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]

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

:code:`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.

:code:`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